Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | |
06b69b18 | 30 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
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 | |
6a488035 TO |
40 | */ |
41 | protected $_task; | |
42 | ||
43 | /** | |
100fef9d | 44 | * Class constructor |
6a488035 | 45 | */ |
00be9182 | 46 | public function __construct($controller, $action = CRM_Core_Action::NONE) { |
6a488035 TO |
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 | * | |
041ab3d1 TO |
72 | * @param CRM_Core_Controller $controller |
73 | * The controller object. | |
6a488035 | 74 | * |
6c8f6e67 EM |
75 | * @param string $formName |
76 | * | |
6a488035 | 77 | * @return string the name of the form that will handle the task |
6a488035 | 78 | */ |
00be9182 | 79 | public function taskName($controller, $formName = 'Search') { |
6a488035 | 80 | // total hack, check POST vars and then session to determine stuff |
e341bbee | 81 | $value = CRM_Utils_Array::value('task', $_POST); |
6a488035 TO |
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 | /** | |
100fef9d | 90 | * Return the form name of the task |
6a488035 TO |
91 | * |
92 | * @return string | |
6a488035 | 93 | */ |
00be9182 | 94 | public function getTaskFormName() { |
6a488035 TO |
95 | return CRM_Utils_String::getClassName($this->_task); |
96 | } | |
97 | ||
ffd93213 EM |
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 | */ | |
00be9182 | 110 | public function shouldReset() { |
6a488035 TO |
111 | return FALSE; |
112 | } | |
113 | } |