3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
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;
53 static $_tasks = NULL;
56 * The optional task array
60 static $_optionalTasks = NULL;
63 * These tasks are the core set of tasks that the user can perform
64 * on a contact / group of contacts
67 * the set of tasks for a group of contacts
69 public static function &tasks() {
70 if (!(self
::$_tasks)) {
71 self
::$_tasks = array(
73 'title' => ts('Delete Participants'),
74 'class' => 'CRM_Event_Form_Task_Delete',
78 'title' => ts('Print Selected Rows'),
79 'class' => 'CRM_Event_Form_Task_Print',
83 'title' => ts('Export Participants'),
85 'CRM_Export_Form_Select',
86 'CRM_Export_Form_Map',
91 'title' => ts('Batch Update Participants Via Profile'),
93 'CRM_Event_Form_Task_PickProfile',
94 'CRM_Event_Form_Task_Batch',
99 'title' => ts('Cancel Registration'),
100 'class' => 'CRM_Event_Form_Task_Cancel',
104 'title' => ts('Send Email to Contacts'),
105 'class' => 'CRM_Event_Form_Task_Email',
109 'title' => ts('New Smart Group'),
110 'class' => 'CRM_Event_Form_Task_SaveSearch',
114 'title' => ts('Update Smart Group'),
115 'class' => 'CRM_Event_Form_Task_SaveSearch_Update',
119 'title' => ts('Change Participant Status'),
120 'class' => 'CRM_Event_Form_Task_ParticipantStatus',
124 'title' => ts('Print Event Name Badges'),
125 'class' => 'CRM_Event_Form_Task_Badge',
129 'title' => ts('Add Contacts to Group'),
130 'class' => 'CRM_Event_Form_Task_AddToGroup',
135 //CRM-4418, check for delete
136 if (!CRM_Core_Permission
::check('delete in CiviEvent')) {
137 unset(self
::$_tasks[1]);
139 //CRM-12920 - check for edit permission
140 if (!CRM_Core_Permission
::check('edit event participants')) {
141 unset(self
::$_tasks[4], self
::$_tasks[5], self
::$_tasks[15]);
145 CRM_Utils_Hook
::searchTasks('event', self
::$_tasks);
146 asort(self
::$_tasks);
147 return self
::$_tasks;
151 * These tasks are the core set of task titles
155 * the set of task titles
157 public static function &taskTitles() {
160 foreach (self
::$_tasks as $id => $value) {
161 // skip Update Smart Group task
162 if ($id != self
::SAVE_SEARCH_UPDATE
) {
163 $titles[$id] = $value['title'];
170 * These tasks get added based on the context the user is in.
173 * the set of optional tasks for a group of contacts
175 public static function &optionalTaskTitle() {
177 14 => self
::$_tasks[14]['title'],
183 * Show tasks selectively based on the permission level
186 * @param int $permission
189 * set of tasks that are valid for the user
191 public static function &permissionedTaskTitles($permission) {
193 if (($permission == CRM_Core_Permission
::EDIT
)
194 || CRM_Core_Permission
::check('edit event participants')
196 $tasks = self
::taskTitles();
200 3 => self
::$_tasks[3]['title'],
201 6 => self
::$_tasks[6]['title'],
205 if (CRM_Core_Permission
::check('delete in CiviEvent')) {
206 $tasks[1] = self
::$_tasks[1]['title'];
213 * These tasks are the core set of tasks that the user can perform
219 * the set of tasks for a group of participants
221 public static function getTask($value) {
223 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
224 // make the print task by default
228 self
::$_tasks[$value]['class'],
229 self
::$_tasks[$value]['result'],