Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
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 and the CiviCRM Licensing Exception. | | |
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 and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
0f03f337 | 31 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
df371444 | 35 | * class to represent the actions that can be performed on a group of voters. |
6a488035 | 36 | * |
df371444 | 37 | * Used by the search forms. |
6a488035 TO |
38 | */ |
39 | class CRM_Campaign_Task { | |
7da04cde | 40 | const INTERVIEW = 1, RESERVE = 2, RELEASE = 3, PRINT_VOTERS = 4; |
6a488035 TO |
41 | |
42 | /** | |
100fef9d | 43 | * The task array |
6a488035 TO |
44 | * |
45 | * @var array | |
6a488035 TO |
46 | */ |
47 | static $_tasks = NULL; | |
48 | ||
49 | /** | |
100fef9d | 50 | * The optional task array |
6a488035 TO |
51 | * |
52 | * @var array | |
6a488035 TO |
53 | */ |
54 | static $_optionalTasks = NULL; | |
55 | ||
56 | /** | |
57 | * These tasks are the core set of tasks that the user can perform | |
58 | * on a voter / group of voters | |
59 | * | |
a6c01b45 CW |
60 | * @return array |
61 | * the set of tasks for a group of voters. | |
6a488035 | 62 | */ |
00be9182 | 63 | public static function &tasks() { |
6a488035 | 64 | if (!(self::$_tasks)) { |
94880218 | 65 | self::$_tasks = array( |
353ffa53 TO |
66 | 1 => array( |
67 | 'title' => ts('Record Respondents Interview'), | |
6a488035 TO |
68 | 'class' => array( |
69 | 'CRM_Campaign_Form_Task_Interview', | |
70 | 'CRM_Campaign_Form_Task_Release', | |
71 | ), | |
72 | 'result' => FALSE, | |
73 | ), | |
23546577 CW |
74 | 2 => array( |
75 | 'title' => ts('Reserve Respondents'), | |
6a488035 TO |
76 | 'class' => array( |
77 | 'CRM_Campaign_Form_Task_Reserve', | |
78 | 'CRM_Campaign_Form_Task_Interview', | |
79 | 'CRM_Campaign_Form_Task_Release', | |
80 | ), | |
81 | 'result' => FALSE, | |
82 | ), | |
23546577 CW |
83 | 3 => array( |
84 | 'title' => ts('Release Respondents'), | |
6a488035 TO |
85 | 'class' => 'CRM_Campaign_Form_Task_Release', |
86 | 'result' => FALSE, | |
87 | ), | |
23546577 CW |
88 | 4 => array( |
89 | 'title' => ts('Print Respondents'), | |
6a488035 TO |
90 | 'class' => 'CRM_Campaign_Form_Task_Print', |
91 | 'result' => FALSE, | |
92 | ), | |
93 | ); | |
94 | } | |
95 | ||
96 | CRM_Utils_Hook::searchTasks('campaign', self::$_tasks); | |
97 | ||
98 | asort(self::$_tasks); | |
99 | ||
100 | return self::$_tasks; | |
101 | } | |
102 | ||
103 | /** | |
104 | * These tasks are the core set of task titles | |
105 | * on voters. | |
106 | * | |
a6c01b45 CW |
107 | * @return array |
108 | * the set of task titles | |
6a488035 | 109 | */ |
00be9182 | 110 | public static function &taskTitles() { |
6a488035 TO |
111 | self::tasks(); |
112 | $titles = array(); | |
113 | foreach (self::$_tasks as $id => $value) { | |
114 | $titles[$id] = $value['title']; | |
115 | } | |
116 | ||
117 | return $titles; | |
118 | } | |
119 | ||
120 | /** | |
100fef9d | 121 | * Show tasks selectively based on the permission level |
6a488035 TO |
122 | * of the user |
123 | * | |
124 | * @param int $permission | |
125 | * | |
a6c01b45 CW |
126 | * @return array |
127 | * set of tasks that are valid for the user | |
6a488035 | 128 | */ |
00be9182 | 129 | public static function &permissionedTaskTitles($permission) { |
6a488035 TO |
130 | $tasks = self::taskTitles(); |
131 | ||
132 | return $tasks; | |
133 | } | |
134 | ||
135 | /** | |
136 | * These tasks are the core set of tasks that the user can perform | |
137 | * on voters. | |
138 | * | |
139 | * @param int $value | |
140 | * | |
a6c01b45 CW |
141 | * @return array |
142 | * the set of tasks for a group of voters. | |
6a488035 | 143 | */ |
00be9182 | 144 | public static function getTask($value) { |
6a488035 TO |
145 | self::tasks(); |
146 | if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) { | |
147 | // make the interview task by default | |
148 | $value = 1; | |
149 | } | |
150 | ||
151 | return array( | |
152 | self::$_tasks[$value]['class'], | |
153 | self::$_tasks[$value]['result'], | |
154 | ); | |
155 | } | |
96025800 | 156 | |
6a488035 | 157 | } |