Merge pull request #4634 from giant-rabbit/JobLogCommandListingBug
[civicrm-core.git] / CRM / Activity / StateMachine / Search.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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 * @protected
41 */
42 protected $_task;
43
44 /**
45 * Class constructor
46 */
47 function __construct($controller, $action = CRM_Core_Action::NONE) {
48 parent::__construct($controller, $action);
49
50 $this->_pages = array();
51
52 $this->_pages['CRM_Activity_Form_Search'] = NULL;
53 list($task, $result) = $this->taskName($controller, 'Search');
54 $this->_task = $task;
55
56 if (is_array($task)) {
57 foreach ($task as $t) {
58 $this->_pages[$t] = NULL;
59 }
60 }
61 else {
62 $this->_pages[$task] = NULL;
63 }
64
65 $this->addSequentialPages($this->_pages, $action);
66 }
67
68 /**
69 * Determine the form name based on the action. This allows us
70 * to avoid using conditional state machine, much more efficient
71 * and simpler
72 *
73 * @param CRM_Core_Controller $controller the controller object
74 *
75 * @param string $formName
76 *
77 * @return string the name of the form that will handle the task
78 * @access protected
79 */
80 function taskName($controller, $formName = 'Search') {
81 // total hack, check POST vars and then session to determine stuff
82 $value = CRM_Utils_Array::value('task', $_POST);
83 if (!isset($value)) {
84 $value = $this->_controller->get('task');
85 }
86 $this->_controller->set('task', $value);
87 return CRM_Activity_Task::getTask($value);
88 }
89
90 /**
91 * Return the form name of the task
92 *
93 * @return string
94 * @access public
95 */
96 function getTaskFormName() {
97 return CRM_Utils_String::getClassName($this->_task);
98 }
99
100 /**
101 * Should the controller reset the session
102 * In some cases, specifically search we want to remember
103 * state across various actions and want to go back to the
104 * beginning from the final state, but retain the same session
105 * values
106 *
107 * @return boolean
108 */
109 /**
110 * @return bool
111 */
112 function shouldReset() {
113 return FALSE;
114 }
115 }
116