From c7b8b4e4f8b431cace9f99ba9a60a3ead89c9b27 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Mon, 13 May 2013 17:03:11 -0700 Subject: [PATCH] CRM-12600 - redirect to search builder if we have the needed info ---------------------------------------- * CRM-12600: Fix behavior of CiviCRM on specific screen(s)when the session has timed out / deleted http://issues.civicrm.org/jira/browse/CRM-12600 --- CRM/Contact/Controller/Search.php | 14 ++++++++++---- CRM/Contact/Form/Search/Custom.php | 7 ++++++- CRM/Contact/Form/Search/Custom/FullText.php | 19 +------------------ CRM/Contact/Selector/Custom.php | 6 ++++-- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/CRM/Contact/Controller/Search.php b/CRM/Contact/Controller/Search.php index 3f3e5136ff..5f80a462ac 100644 --- a/CRM/Contact/Controller/Search.php +++ b/CRM/Contact/Controller/Search.php @@ -66,7 +66,7 @@ class CRM_Contact_Controller_Search extends CRM_Core_Controller { } public function invalidKey() { - $message = ts('Because your session is timed out, we have reset the search page.'); + $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 @@ -74,17 +74,23 @@ class CRM_Contact_Controller_Search extends CRM_Core_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 { - $path = 'civicrm/contact/search/advanced'; + 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, 'reset=1'); + $url = CRM_Utils_System::url($path, $args); CRM_Utils_System::redirect($url); } diff --git a/CRM/Contact/Form/Search/Custom.php b/CRM/Contact/Form/Search/Custom.php index 8a77cf44b6..97c8f773b8 100644 --- a/CRM/Contact/Form/Search/Custom.php +++ b/CRM/Contact/Form/Search/Custom.php @@ -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; } diff --git a/CRM/Contact/Form/Search/Custom/FullText.php b/CRM/Contact/Form/Search/Custom/FullText.php index c6f8426460..c56719df91 100644 --- a/CRM/Contact/Form/Search/Custom/FullText.php +++ b/CRM/Contact/Form/Search/Custom/FullText.php @@ -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 diff --git a/CRM/Contact/Selector/Custom.php b/CRM/Contact/Selector/Custom.php index fd10d7f42a..8fad5d7164 100644 --- a/CRM/Contact/Selector/Custom.php +++ b/CRM/Contact/Selector/Custom.php @@ -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 -- 2.25.1