Skip to content
Snippets Groups Projects
Commit 7e887ebf authored by lobo's avatar lobo
Browse files

Merge pull request #730 from dlobo/CRM-12600

CRM-12600
parents 12ec93d7 c7b8b4e4
Branches
Tags
No related merge requests found
......@@ -64,5 +64,35 @@ class CRM_Contact_Controller_Search extends CRM_Core_Controller {
public function selectorName() {
return $this->get('selectorName');
}
public function invalidKey() {
$message = ts('Because your session timed out, we have reset the search page.');
CRM_Core_Session::setStatus($message);
// see if we can figure out the url and redirect to the right search form
// note that this happens really early on, so we cant use any of the form or controller
// variables
$config = CRM_Core_Config::singleton();
$qString = $_GET[$config->userFrameworkURLVar];
$args = "reset=1";
$path = 'civicrm/contact/search/advanced';
if (strpos($qString, 'basic') !== FALSE) {
$path = 'civicrm/contact/search/basic';
}
else if (strpos($qString, 'builder') !== FALSE) {
$path = 'civicrm/contact/search/builder';
}
else if (
strpos($qString, 'custom') !== FALSE &&
isset($_REQUEST['csid'])
) {
$path = 'civicrm/contact/search/custom';
$args = "reset=1&csid={$_REQUEST['csid']}";
}
$url = CRM_Utils_System::url($path, $args);
CRM_Utils_System::redirect($url);
}
}
......@@ -45,7 +45,8 @@ class CRM_Contact_Form_Search_Custom extends CRM_Contact_Form_Search {
$ssID = CRM_Utils_Request::retrieve('ssID', 'Integer', $this);
$gID = CRM_Utils_Request::retrieve('gid', 'Integer', $this);
list($this->_customSearchID,
list(
$this->_customSearchID,
$this->_customSearchClass,
$formValues
) = CRM_Contact_BAO_SearchCustom::details($csID, $ssID, $gID);
......@@ -54,6 +55,10 @@ class CRM_Contact_Form_Search_Custom extends CRM_Contact_Form_Search {
CRM_Core_Error::fatal('Could not get details for custom search.');
}
// stash this as a hidden element so we can potentially go there if the session
// is reset but this is available in the POST
$this->addElement('hidden', 'csid', $csID);
if (!empty($formValues)) {
$this->_formValues = $formValues;
}
......
......@@ -478,21 +478,6 @@ GROUP BY et.entity_id
$contactSQL[] = "
SELECT distinct ca.id
FROM civicrm_activity ca
INNER JOIN civicrm_contact c ON ca.source_contact_id = c.id
LEFT JOIN civicrm_email e ON e.contact_id = c.id
LEFT JOIN civicrm_option_group og ON og.name = 'activity_type'
LEFT JOIN civicrm_option_value ov ON ( ov.option_group_id = og.id )
WHERE ( (c.sort_name LIKE {$this->_text} OR c.display_name LIKE {$this->_text}) OR
(e.email LIKE {$this->_text} AND
ca.activity_type_id = ov.value AND
ov.name IN ('Inbound Email', 'Email') ) )
AND (ca.is_deleted = 0 OR ca.is_deleted IS NULL)
AND (c.is_deleted = 0 OR c.is_deleted IS NULL)
";
$contactSQL[] = "
SELECT distinct ca.id
FROM civicrm_activity ca
INNER JOIN civicrm_activity_contact cat ON cat.activity_id = ca.id
INNER JOIN civicrm_contact c ON cat.contact_id = c.id
LEFT JOIN civicrm_email e ON cat.contact_id = e.contact_id
......@@ -916,9 +901,7 @@ INSERT INTO {$this->_tableName}
( table_name, activity_id, subject, details, contact_id, sort_name, record_type,
activity_type_id, case_id, client_id )
SELECT 'Activity', ca.id, substr(ca.subject, 1, 50), substr(ca.details, 1, 250),
c1.id, c1.sort_name,
c2.id, c2.sort_name,
c3.id, c3.sort_name,
c1.id, c1.sort_name, cac.record_type_id,
ca.activity_type_id,
cca.case_id,
ccc.contact_id as client_id
......
......@@ -144,8 +144,10 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
$this->_search = new $customSearchClass( $formValues );
}
else {
$customSearchFile = $ext->keyToPath($customSearchClass, 'search');
$this->_search = new $ext->keyToClass($customSearchClass, 'search')( $formValues );
$fnName = $ext->keyToPath;
$customSearchFile = $fnName($customSearchClass, 'search');
$className = $ext->keyToClass($customSearchClass, 'search');
$this->_search = new $className($formValues);
}
}
//end of constructor
......
......@@ -274,8 +274,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
}
if (!$key) {
$msg = ts('We can\'t load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site adminstrator for assistance.') . '<br /><br />' . ts('Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.') . '<br /><br />' . ts('Error type: Could not find a valid session key.');
CRM_Core_Error::fatal($msg);
$this->invalidKey();
}
$this->_key = $key;
......@@ -749,5 +748,17 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
list($pageName, $action) = $actionName;
return $this->_pages[$pageName]->cancelAction();
}
}
/**
* Write a simple fatal error message. Other controllers can decide to do something else
* and present the user a better message and/or redirect to the same page with a reset url
*
* @return void
*
*/
public function invalidKey() {
$msg = ts('We can\'t load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site adminstrator for assistance.') . '<br /><br />' . ts('Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.') . '<br /><br />' . ts('Error type: Could not find a valid session key.');
CRM_Core_Error::fatal($msg);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment