3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * class to represent the actions that can be performed on a group of
22 * contacts (CiviMember)
23 * used by the search forms
26 class CRM_Member_Task
extends CRM_Core_Task
{
30 const LABEL_MEMBERS
= 201;
35 public static $objectType = 'membership';
38 * These tasks are the core set of tasks that the user can perform
39 * on a contact / group of contacts
42 * the set of tasks for a group of contacts
44 public static function tasks() {
47 self
::TASK_DELETE
=> [
48 'title' => ts('Delete memberships'),
49 'class' => 'CRM_Member_Form_Task_Delete',
53 'title' => ts('Print selected rows'),
54 'class' => 'CRM_Member_Form_Task_Print',
57 self
::TASK_EXPORT
=> [
58 'title' => ts('Export members'),
60 'CRM_Export_Form_Select',
61 'CRM_Export_Form_Map',
66 'title' => ts('Email - send now (to %1 or less)', [
68 ->get('simple_mail_limit'),
70 'class' => 'CRM_Member_Form_Task_Email',
73 self
::BATCH_UPDATE
=> [
74 'title' => ts('Update multiple memberships'),
76 'CRM_Member_Form_Task_PickProfile',
77 'CRM_Member_Form_Task_Batch',
81 self
::LABEL_MEMBERS
=> [
82 'title' => ts('Mailing labels - print'),
84 'CRM_Member_Form_Task_Label',
89 'title' => ts('Print/merge document for memberships'),
90 'class' => 'CRM_Member_Form_Task_PDFLetter',
93 self
::SAVE_SEARCH
=> [
94 'title' => ts('Group - create smart group'),
95 'class' => 'CRM_Contact_Form_Task_SaveSearch',
98 self
::SAVE_SEARCH_UPDATE
=> [
99 'title' => ts('Group - update smart group'),
100 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update',
105 //CRM-4418, check for delete
106 if (!CRM_Core_Permission
::check('delete in CiviMember')) {
107 unset(self
::$_tasks[self
::TASK_DELETE
]);
109 //CRM-12920 - check for edit permission
110 if (!CRM_Core_Permission
::check('edit memberships')) {
111 unset(self
::$_tasks[self
::BATCH_UPDATE
]);
117 return self
::$_tasks;
121 * These tasks are the core set of task titles
125 * the set of task titles
127 public static function taskTitles() {
128 return parent
::taskTitles();
132 * Show tasks selectively based on the permission level
135 * @param int $permission
136 * @param array $params
139 * set of tasks that are valid for the user
141 public static function permissionedTaskTitles($permission, $params = []) {
142 if (($permission == CRM_Core_Permission
::EDIT
)
143 || CRM_Core_Permission
::check('edit memberships')
145 $tasks = self
::taskTitles();
149 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
150 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
153 if (CRM_Core_Permission
::check('delete in CiviMember')) {
154 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
158 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
163 * These tasks are the core set of tasks that the user can perform
169 * the set of tasks for a group of members
171 public static function getTask($value) {
173 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
174 // Make the print task the default
175 $value = self
::TASK_PRINT
;
177 return parent
::getTask($value);