INFRA-132 - CRM/Activity - Convert single-line @param to multi-line
[civicrm-core.git] / CRM / Activity / StateMachine / Search.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27 /**
28 *
29 * @package CRM
30 * @copyright CiviCRM LLC (c) 2004-2014
31 * $Id$
32 *
33 */
34 class CRM_Activity_StateMachine_Search extends CRM_Core_StateMachine {
35
36 /**
37 * The task that the wizard is currently processing
38 *
39 * @var string
40 */
41 protected $_task;
42
43 /**
44 * Class constructor
45 */
46 public function __construct($controller, $action = CRM_Core_Action::NONE) {
47 parent::__construct($controller, $action);
48
49 $this->_pages = array();
50
51 $this->_pages['CRM_Activity_Form_Search'] = NULL;
52 list($task, $result) = $this->taskName($controller, 'Search');
53 $this->_task = $task;
54
55 if (is_array($task)) {
56 foreach ($task as $t) {
57 $this->_pages[$t] = NULL;
58 }
59 }
60 else {
61 $this->_pages[$task] = NULL;
62 }
63
64 $this->addSequentialPages($this->_pages, $action);
65 }
66
67 /**
68 * Determine the form name based on the action. This allows us
69 * to avoid using conditional state machine, much more efficient
70 * and simpler
71 *
72 * @param CRM_Core_Controller $controller
73 * The controller object.
74 *
75 * @param string $formName
76 *
77 * @return string the name of the form that will handle the task
78 */
79 public function taskName($controller, $formName = 'Search') {
80 // total hack, check POST vars and then session to determine stuff
81 $value = CRM_Utils_Array::value('task', $_POST);
82 if (!isset($value)) {
83 $value = $this->_controller->get('task');
84 }
85 $this->_controller->set('task', $value);
86 return CRM_Activity_Task::getTask($value);
87 }
88
89 /**
90 * Return the form name of the task
91 *
92 * @return string
93 */
94 public function getTaskFormName() {
95 return CRM_Utils_String::getClassName($this->_task);
96 }
97
98 /**
99 * Should the controller reset the session
100 * In some cases, specifically search we want to remember
101 * state across various actions and want to go back to the
102 * beginning from the final state, but retain the same session
103 * values
104 *
105 * @return boolean
106 */
107 /**
108 * @return bool
109 */
110 public function shouldReset() {
111 return FALSE;
112 }
113 }