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