From c02edd0e8f6755bbc02cba0dfbcad15d25d4de22 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Mon, 13 May 2013 12:19:38 -0700 Subject: [PATCH] CRM-12600 ---------------------------------------- * CRM-12600: Fix behavior of CiviCRM on certain screen when the session has timed out / deleted http://issues.civicrm.org/jira/browse/CRM-12600 --- CRM/Contact/Controller/Search.php | 24 ++++++++++++++++++++++++ CRM/Core/Controller.php | 17 ++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/Controller/Search.php b/CRM/Contact/Controller/Search.php index bfaa69f211..3f3e5136ff 100644 --- a/CRM/Contact/Controller/Search.php +++ b/CRM/Contact/Controller/Search.php @@ -64,5 +64,29 @@ class CRM_Contact_Controller_Search extends CRM_Core_Controller { public function selectorName() { return $this->get('selectorName'); } + + public function invalidKey() { + $message = ts('Because your session is 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]; + 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'; + } + + $url = CRM_Utils_System::url($path, 'reset=1'); + CRM_Utils_System::redirect($url); + } + } diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index 053d961984..9fdd59e0c1 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -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.') . '

' . 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.') . '

' . 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.') . '

' . 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.') . '

' . ts('Error type: Could not find a valid session key.'); + CRM_Core_Error::fatal($msg); + } + +} -- 2.25.1