Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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-2013 | |
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 | * @return string the name of the form that will handle the task | |
76 | * @access protected | |
77 | */ | |
78 | function taskName($controller, $formName = 'Search') { | |
79 | // total hack, check POST vars and then session to determine stuff | |
80 | // fix value if print button is pressed | |
81 | if (CRM_Utils_Array::value('_qf_' . $formName . '_next_print', $_POST)) { | |
82 | $value = CRM_Activity_Task::PRINT_ACTIVITIES; | |
83 | } | |
84 | else { | |
85 | $value = CRM_Utils_Array::value('task', $_POST); | |
86 | } | |
87 | if (!isset($value)) { | |
88 | $value = $this->_controller->get('task'); | |
89 | } | |
90 | $this->_controller->set('task', $value); | |
91 | return CRM_Activity_Task::getTask($value); | |
92 | } | |
93 | ||
94 | /** | |
95 | * return the form name of the task | |
96 | * | |
97 | * @return string | |
98 | * @access public | |
99 | */ | |
100 | function getTaskFormName() { | |
101 | return CRM_Utils_String::getClassName($this->_task); | |
102 | } | |
103 | ||
104 | function shouldReset() { | |
105 | return FALSE; | |
106 | } | |
107 | } | |
108 |