Merge pull request #18631 from eileenmcnaughton/ppp
[civicrm-core.git] / CRM / Contact / Controller / Search.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * This class is used by the Search functionality.
20 *
21 * - the search controller is used for building/processing multiform
22 * searches.
23 *
24 * Typically the first form will display the search criteria and it's results
25 *
26 * The second form is used to process search results with the associated actions.
27 */
28 class CRM_Contact_Controller_Search extends CRM_Core_Controller {
29
30 /**
31 * Class constructor.
32 *
33 * @param string $title
34 * @param bool $modal
35 * @param int|mixed|null $action
36 */
37 public function __construct($title = NULL, $modal = TRUE, $action = CRM_Core_Action::NONE) {
38 parent::__construct($title, $modal);
39
40 $this->_stateMachine = new CRM_Contact_StateMachine_Search($this, $action);
41
42 // create and instantiate the pages
43 $this->addPages($this->_stateMachine, $action);
44
45 // add all the actions
46 $this->addActions();
47 }
48
49 /**
50 * @return mixed
51 */
52 public function selectorName() {
53 return $this->get('selectorName');
54 }
55
56 public function invalidKey() {
57 $message = ts('Because your session timed out, we have reset the search page.');
58 CRM_Core_Session::setStatus($message);
59
60 // see if we can figure out the url and redirect to the right search form
61 // note that this happens really early on, so we can't use any of the form or controller
62 // variables
63 $qString = CRM_Utils_System::currentPath();
64 $args = "reset=1";
65 $path = 'civicrm/contact/search/advanced';
66 if (strpos($qString, 'basic') !== FALSE) {
67 $path = 'civicrm/contact/search/basic';
68 }
69 elseif (strpos($qString, 'builder') !== FALSE) {
70 $path = 'civicrm/contact/search/builder';
71 }
72 elseif (
73 strpos($qString, 'custom') !== FALSE &&
74 isset($_REQUEST['csid'])
75 ) {
76 $path = 'civicrm/contact/search/custom';
77 $args = "reset=1&csid={$_REQUEST['csid']}";
78 }
79
80 $url = CRM_Utils_System::url($path, $args);
81 CRM_Utils_System::redirect($url);
82 }
83
84 }