3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * class to represent the actions that can be performed on a group of contacts
38 * used by the search forms
41 class CRM_Event_Task
{
42 // Value for SAVE_SEARCH is set to 13 in accordance with CRM_Contact_Task::SAVE_SEARCH
43 CONST DELETE_EVENTS
= 1, PRINT_EVENTS
= 2, EXPORT_EVENTS
= 3, BATCH_EVENTS
= 4, CANCEL_REGISTRATION
= 5, EMAIL_CONTACTS
= 6,
44 // Value for LABEL_CONTACTS is set to 16 in accordance with CRM_Contact_Task::LABEL_CONTACTS
45 SAVE_SEARCH
= 13, SAVE_SEARCH_UPDATE
= 14, PARTICIPANT_STATUS
= 15,
46 LABEL_CONTACTS
= 16, GROUP_CONTACTS
= 20;
54 static $_tasks = NULL;
57 * The optional task array
62 static $_optionalTasks = NULL;
65 * These tasks are the core set of tasks that the user can perform
66 * on a contact / group of contacts
68 * @return array the set of tasks for a group of contacts
72 static function &tasks() {
73 if (!(self
::$_tasks)) {
74 self
::$_tasks = array(1 => array(
75 'title' => ts('Delete Participants'),
76 'class' => 'CRM_Event_Form_Task_Delete',
80 'title' => ts('Print Selected Rows'),
81 'class' => 'CRM_Event_Form_Task_Print',
85 'title' => ts('Export Participants'),
87 'CRM_Export_Form_Select',
88 'CRM_Export_Form_Map',
93 'title' => ts('Batch Update Participants Via Profile'),
95 'CRM_Event_Form_Task_PickProfile',
96 'CRM_Event_Form_Task_Batch',
101 'title' => ts('Cancel Registration'),
102 'class' => 'CRM_Event_Form_Task_Cancel',
106 'title' => ts('Send Email to Contacts'),
107 'class' => 'CRM_Event_Form_Task_Email',
111 'title' => ts('New Smart Group'),
112 'class' => 'CRM_Event_Form_Task_SaveSearch',
116 'title' => ts('Update Smart Group'),
117 'class' => 'CRM_Event_Form_Task_SaveSearch_Update',
121 'title' => ts('Change Participant Status'),
122 'class' => 'CRM_Event_Form_Task_ParticipantStatus',
126 'title' => ts('Print Event Name Badges'),
127 'class' => 'CRM_Event_Form_Task_Badge',
131 'title' => ts('Add Contacts to Group'),
132 'class' => 'CRM_Event_Form_Task_AddToGroup',
137 //CRM-4418, check for delete
138 if (!CRM_Core_Permission
::check('delete in CiviEvent')) {
139 unset(self
::$_tasks[1]);
141 //CRM-12920 - check for edit permission
142 if( !CRM_Core_Permission
::check('edit event participants') ){
143 unset(self
::$_tasks[4],self
::$_tasks[5],self
::$_tasks[15]);
147 CRM_Utils_Hook
::searchTasks('event', self
::$_tasks);
148 asort(self
::$_tasks);
149 return self
::$_tasks;
153 * These tasks are the core set of task titles
156 * @return array the set of task titles
160 static function &taskTitles() {
163 foreach (self
::$_tasks as $id => $value) {
164 // skip Update Smart Group task
165 if ($id != self
::SAVE_SEARCH_UPDATE
) {
166 $titles[$id] = $value['title'];
173 * These tasks get added based on the context the user is in
175 * @return array the set of optional tasks for a group of contacts
179 static function &optionalTaskTitle() {
181 14 => self
::$_tasks[14]['title'],
187 * Show tasks selectively based on the permission level
190 * @param int $permission
192 * @return array set of tasks that are valid for the user
195 static function &permissionedTaskTitles($permission) {
197 if (($permission == CRM_Core_Permission
::EDIT
)
198 || CRM_Core_Permission
::check('edit event participants')
200 $tasks = self
::taskTitles();
204 3 => self
::$_tasks[3]['title'],
205 6 => self
::$_tasks[6]['title'],
209 if (CRM_Core_Permission
::check('delete in CiviEvent')) {
210 $tasks[1] = self
::$_tasks[1]['title'];
217 * These tasks are the core set of tasks that the user can perform
222 * @return array the set of tasks for a group of participants
226 static function getTask($value) {
228 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
229 // make the print task by default
233 self
::$_tasks[$value]['class'],
234 self
::$_tasks[$value]['result'],