Merge pull request #18779 from jaapjansma/dev_report_53
[civicrm-core.git] / CRM / Contact / Controller / Search.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
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 *
c037736a 26 * The second form is used to process search results with the associated actions.
6a488035
TO
27 */
28class CRM_Contact_Controller_Search extends CRM_Core_Controller {
29
233e08f1 30 protected $entity = 'Contact';
31
6a488035 32 /**
2e2605fe
EM
33 * Class constructor.
34 *
35 * @param string $title
36 * @param bool $modal
37 * @param int|mixed|null $action
6a488035 38 */
00be9182 39 public function __construct($title = NULL, $modal = TRUE, $action = CRM_Core_Action::NONE) {
6a488035
TO
40 parent::__construct($title, $modal);
41
42 $this->_stateMachine = new CRM_Contact_StateMachine_Search($this, $action);
43
44 // create and instantiate the pages
45 $this->addPages($this->_stateMachine, $action);
46
47 // add all the actions
48 $this->addActions();
233e08f1 49 $this->set('entity', $this->entity);
6a488035
TO
50 }
51
86538308
EM
52 /**
53 * @return mixed
54 */
6a488035
TO
55 public function selectorName() {
56 return $this->get('selectorName');
57 }
c02edd0e
DL
58
59 public function invalidKey() {
c7b8b4e4 60 $message = ts('Because your session timed out, we have reset the search page.');
c02edd0e
DL
61 CRM_Core_Session::setStatus($message);
62
63 // see if we can figure out the url and redirect to the right search form
b44e3f84 64 // note that this happens really early on, so we can't use any of the form or controller
c02edd0e 65 // variables
13594d55 66 $qString = CRM_Utils_System::currentPath();
c7b8b4e4
DL
67 $args = "reset=1";
68 $path = 'civicrm/contact/search/advanced';
c02edd0e
DL
69 if (strpos($qString, 'basic') !== FALSE) {
70 $path = 'civicrm/contact/search/basic';
71 }
4c9b6178 72 elseif (strpos($qString, 'builder') !== FALSE) {
c02edd0e
DL
73 $path = 'civicrm/contact/search/builder';
74 }
4c9b6178 75 elseif (
c7b8b4e4
DL
76 strpos($qString, 'custom') !== FALSE &&
77 isset($_REQUEST['csid'])
78 ) {
79 $path = 'civicrm/contact/search/custom';
80 $args = "reset=1&csid={$_REQUEST['csid']}";
c02edd0e
DL
81 }
82
c7b8b4e4 83 $url = CRM_Utils_System::url($path, $args);
c02edd0e
DL
84 CRM_Utils_System::redirect($url);
85 }
86
6a488035 87}