Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
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 | /** | |
6a488035 | 29 | * @package CRM |
8c9251b3 | 30 | * @copyright CiviCRM LLC (c) 2004-2018 |
6a488035 TO |
31 | * |
32 | */ | |
33 | ||
34 | /** | |
35 | * class to represent the actions that can be performed on a group of contacts | |
36 | * used by the search forms | |
37 | * | |
38 | */ | |
8fd26836 | 39 | class CRM_Event_Task extends CRM_Core_Task { |
6a488035 | 40 | |
8fd26836 MW |
41 | const |
42 | // Event tasks | |
43 | CANCEL_REGISTRATION = 301, | |
44 | PARTICIPANT_STATUS = 302; | |
6a488035 | 45 | |
8fd26836 | 46 | static $objectType = 'event'; |
6a488035 TO |
47 | |
48 | /** | |
49 | * These tasks are the core set of tasks that the user can perform | |
50 | * on a contact / group of contacts | |
51 | * | |
8fd26836 MW |
52 | * @return array The set of tasks for a group of contacts |
53 | * [ 'title' => The Task title, | |
54 | * 'class' => The Task Form class name, | |
55 | * 'result => Boolean. FIXME: Not sure what this is for | |
56 | * ] | |
6a488035 | 57 | */ |
8fd26836 MW |
58 | public static function tasks() { |
59 | if (!self::$_tasks) { | |
0479b4c8 | 60 | self::$_tasks = array( |
8fd26836 | 61 | self::TASK_DELETE => array( |
7f82e636 | 62 | 'title' => ts('Delete participants from event'), |
6a488035 TO |
63 | 'class' => 'CRM_Event_Form_Task_Delete', |
64 | 'result' => FALSE, | |
65 | ), | |
8fd26836 | 66 | self::TASK_PRINT => array( |
7f82e636 | 67 | 'title' => ts('Print selected rows'), |
6a488035 TO |
68 | 'class' => 'CRM_Event_Form_Task_Print', |
69 | 'result' => FALSE, | |
70 | ), | |
8fd26836 | 71 | self::TASK_EXPORT => array( |
7f82e636 | 72 | 'title' => ts('Export participants'), |
6a488035 TO |
73 | 'class' => array( |
74 | 'CRM_Export_Form_Select', | |
75 | 'CRM_Export_Form_Map', | |
76 | ), | |
77 | 'result' => FALSE, | |
78 | ), | |
8fd26836 | 79 | self::BATCH_UPDATE => array( |
b581842f | 80 | 'title' => ts('Update multiple participants'), |
6a488035 TO |
81 | 'class' => array( |
82 | 'CRM_Event_Form_Task_PickProfile', | |
83 | 'CRM_Event_Form_Task_Batch', | |
84 | ), | |
85 | 'result' => TRUE, | |
86 | ), | |
8fd26836 | 87 | self::CANCEL_REGISTRATION => array( |
7f82e636 | 88 | 'title' => ts('Cancel registration'), |
6a488035 TO |
89 | 'class' => 'CRM_Event_Form_Task_Cancel', |
90 | 'result' => FALSE, | |
91 | ), | |
8fd26836 | 92 | self::TASK_EMAIL => array( |
21d01648 MW |
93 | 'title' => ts('Email - send now (to %1 or less)', array( |
94 | 1 => Civi::settings() | |
95 | ->get('simple_mail_limit'), | |
96 | )), | |
6a488035 TO |
97 | 'class' => 'CRM_Event_Form_Task_Email', |
98 | 'result' => TRUE, | |
99 | ), | |
8fd26836 | 100 | self::SAVE_SEARCH => array( |
7f12f044 | 101 | 'title' => ts('Group - create smart group'), |
6a488035 TO |
102 | 'class' => 'CRM_Event_Form_Task_SaveSearch', |
103 | 'result' => TRUE, | |
104 | ), | |
8fd26836 | 105 | self::SAVE_SEARCH_UPDATE => array( |
7f12f044 | 106 | 'title' => ts('Group - update smart group'), |
6a488035 TO |
107 | 'class' => 'CRM_Event_Form_Task_SaveSearch_Update', |
108 | 'result' => TRUE, | |
109 | ), | |
8fd26836 | 110 | self::PARTICIPANT_STATUS => array( |
1aa1efef | 111 | 'title' => ts('Participant status - change'), |
6a488035 TO |
112 | 'class' => 'CRM_Event_Form_Task_ParticipantStatus', |
113 | 'result' => TRUE, | |
114 | ), | |
8fd26836 | 115 | self::LABEL_CONTACTS => array( |
79e4c2ad | 116 | 'title' => ts('Name badges - print'), |
6a488035 TO |
117 | 'class' => 'CRM_Event_Form_Task_Badge', |
118 | 'result' => FALSE, | |
119 | ), | |
765b5b56 | 120 | self::PDF_LETTER => array( |
7f82e636 | 121 | 'title' => ts('PDF letter - print for participants'), |
9cda9396 TM |
122 | 'class' => 'CRM_Event_Form_Task_PDF', |
123 | 'result' => TRUE, | |
124 | ), | |
8fd26836 | 125 | self::GROUP_ADD => array( |
7f82e636 | 126 | 'title' => ts('Group - add contacts'), |
bb7b01e6 SD |
127 | 'class' => 'CRM_Event_Form_Task_AddToGroup', |
128 | 'result' => FALSE, | |
129 | ), | |
6a488035 TO |
130 | ); |
131 | ||
132 | //CRM-4418, check for delete | |
133 | if (!CRM_Core_Permission::check('delete in CiviEvent')) { | |
8fd26836 | 134 | unset(self::$_tasks[self::TASK_DELETE]); |
6a488035 | 135 | } |
447c72b5 | 136 | //CRM-12920 - check for edit permission |
481a74f4 | 137 | if (!CRM_Core_Permission::check('edit event participants')) { |
8fd26836 | 138 | unset(self::$_tasks[self::BATCH_UPDATE], self::$_tasks[self::CANCEL_REGISTRATION], self::$_tasks[self::PARTICIPANT_STATUS]); |
447c72b5 | 139 | } |
6a488035 | 140 | |
8fd26836 | 141 | parent::tasks(); |
4d73a5a7 | 142 | } |
18f6ea53 | 143 | |
6a488035 TO |
144 | return self::$_tasks; |
145 | } | |
146 | ||
6a488035 | 147 | /** |
100fef9d | 148 | * Show tasks selectively based on the permission level |
6a488035 TO |
149 | * of the user |
150 | * | |
151 | * @param int $permission | |
8fd26836 | 152 | * @param array $params |
6a488035 | 153 | * |
a6c01b45 CW |
154 | * @return array |
155 | * set of tasks that are valid for the user | |
6a488035 | 156 | */ |
8fd26836 | 157 | public static function permissionedTaskTitles($permission, $params = array()) { |
6a488035 TO |
158 | if (($permission == CRM_Core_Permission::EDIT) |
159 | || CRM_Core_Permission::check('edit event participants') | |
160 | ) { | |
161 | $tasks = self::taskTitles(); | |
162 | } | |
163 | else { | |
164 | $tasks = array( | |
8fd26836 MW |
165 | self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], |
166 | self::TASK_EMAIL => self::$_tasks[self::TASK_EMAIL]['title'], | |
6a488035 TO |
167 | ); |
168 | ||
169 | //CRM-4418, | |
170 | if (CRM_Core_Permission::check('delete in CiviEvent')) { | |
8fd26836 | 171 | $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title']; |
6a488035 TO |
172 | } |
173 | } | |
8fd26836 MW |
174 | |
175 | $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); | |
6a488035 TO |
176 | return $tasks; |
177 | } | |
178 | ||
179 | /** | |
180 | * These tasks are the core set of tasks that the user can perform | |
181 | * on participants | |
182 | * | |
183 | * @param int $value | |
184 | * | |
a6c01b45 CW |
185 | * @return array |
186 | * the set of tasks for a group of participants | |
6a488035 | 187 | */ |
00be9182 | 188 | public static function getTask($value) { |
6a488035 TO |
189 | self::tasks(); |
190 | if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) { | |
191 | // make the print task by default | |
8fd26836 | 192 | $value = self::TASK_PRINT; |
6a488035 | 193 | } |
8fd26836 | 194 | return parent::getTask($value); |
6a488035 | 195 | } |
96025800 | 196 | |
6a488035 | 197 | } |