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