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
19 * class to represent the actions that can be performed on a group of
20 * contacts (CiviMember)
21 * used by the search forms
24 class CRM_Member_Task
extends CRM_Core_Task
{
28 const LABEL_MEMBERS
= 201;
33 public static $objectType = 'membership';
36 * These tasks are the core set of tasks that the user can perform
37 * on a contact / group of contacts
40 * the set of tasks for a group of contacts
42 public static function tasks() {
44 self
::TASK_DELETE
=> [
45 'title' => ts('Delete memberships'),
46 'class' => 'CRM_Member_Form_Task_Delete',
50 'title' => ts('Print selected rows'),
51 'class' => 'CRM_Member_Form_Task_Print',
54 self
::TASK_EXPORT
=> [
55 'title' => ts('Export members'),
57 'CRM_Member_Export_Form_Select',
58 'CRM_Member_Export_Form_Map',
63 'title' => ts('Email - send now (to %1 or less)', [
65 ->get('simple_mail_limit'),
67 'class' => 'CRM_Member_Form_Task_Email',
70 self
::BATCH_UPDATE
=> [
71 'title' => ts('Update multiple memberships'),
73 'CRM_Member_Form_Task_PickProfile',
74 'CRM_Member_Form_Task_Batch',
78 self
::LABEL_MEMBERS
=> [
79 'title' => ts('Mailing labels - print'),
81 'CRM_Member_Form_Task_Label',
86 'title' => ts('Print/merge document for memberships'),
87 'class' => 'CRM_Member_Form_Task_PDFLetter',
90 self
::SAVE_SEARCH
=> [
91 'title' => ts('Group - create smart group'),
92 'class' => 'CRM_Contact_Form_Task_SaveSearch',
95 self
::SAVE_SEARCH_UPDATE
=> [
96 'title' => ts('Group - update smart group'),
97 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update',
102 //CRM-4418, check for delete
103 if (!CRM_Core_Permission
::check('delete in CiviMember')) {
104 unset(self
::$_tasks[self
::TASK_DELETE
]);
106 //CRM-12920 - check for edit permission
107 if (!CRM_Core_Permission
::check('edit memberships')) {
108 unset(self
::$_tasks[self
::BATCH_UPDATE
]);
113 return self
::$_tasks;
117 * These tasks are the core set of task titles
121 * the set of task titles
123 public static function taskTitles() {
124 return parent
::taskTitles();
128 * Show tasks selectively based on the permission level
131 * @param int $permission
132 * @param array $params
135 * set of tasks that are valid for the user
137 public static function permissionedTaskTitles($permission, $params = []) {
138 if (($permission == CRM_Core_Permission
::EDIT
)
139 || CRM_Core_Permission
::check('edit memberships')
141 $tasks = self
::taskTitles();
145 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
146 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
149 if (CRM_Core_Permission
::check('delete in CiviMember')) {
150 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
154 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
159 * These tasks are the core set of tasks that the user can perform
165 * the set of tasks for a group of members
167 public static function getTask($value) {
169 if (!$value ||
empty(self
::$_tasks[$value])) {
170 // Make the print task the default
171 $value = self
::TASK_PRINT
;
173 return parent
::getTask($value);