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() {
45 self
::TASK_DELETE
=> [
46 'title' => ts('Delete memberships'),
47 'class' => 'CRM_Member_Form_Task_Delete',
51 'title' => ts('Print selected rows'),
52 'class' => 'CRM_Member_Form_Task_Print',
55 self
::TASK_EXPORT
=> [
56 'title' => ts('Export members'),
58 'CRM_Export_Form_Select',
59 'CRM_Export_Form_Map',
64 'title' => ts('Email - send now (to %1 or less)', [
66 ->get('simple_mail_limit'),
68 'class' => 'CRM_Member_Form_Task_Email',
71 self
::BATCH_UPDATE
=> [
72 'title' => ts('Update multiple memberships'),
74 'CRM_Member_Form_Task_PickProfile',
75 'CRM_Member_Form_Task_Batch',
79 self
::LABEL_MEMBERS
=> [
80 'title' => ts('Mailing labels - print'),
82 'CRM_Member_Form_Task_Label',
87 'title' => ts('Print/merge document for memberships'),
88 'class' => 'CRM_Member_Form_Task_PDFLetter',
91 self
::SAVE_SEARCH
=> [
92 'title' => ts('Group - create smart group'),
93 'class' => 'CRM_Contact_Form_Task_SaveSearch',
96 self
::SAVE_SEARCH_UPDATE
=> [
97 'title' => ts('Group - update smart group'),
98 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update',
103 //CRM-4418, check for delete
104 if (!CRM_Core_Permission
::check('delete in CiviMember')) {
105 unset(self
::$_tasks[self
::TASK_DELETE
]);
107 //CRM-12920 - check for edit permission
108 if (!CRM_Core_Permission
::check('edit memberships')) {
109 unset(self
::$_tasks[self
::BATCH_UPDATE
]);
115 return self
::$_tasks;
119 * These tasks are the core set of task titles
123 * the set of task titles
125 public static function taskTitles() {
126 return parent
::taskTitles();
130 * Show tasks selectively based on the permission level
133 * @param int $permission
134 * @param array $params
137 * set of tasks that are valid for the user
139 public static function permissionedTaskTitles($permission, $params = []) {
140 if (($permission == CRM_Core_Permission
::EDIT
)
141 || CRM_Core_Permission
::check('edit memberships')
143 $tasks = self
::taskTitles();
147 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
148 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
151 if (CRM_Core_Permission
::check('delete in CiviMember')) {
152 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
156 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
161 * These tasks are the core set of tasks that the user can perform
167 * the set of tasks for a group of members
169 public static function getTask($value) {
171 if (!$value ||
empty(self
::$_tasks[$value])) {
172 // Make the print task the default
173 $value = self
::TASK_PRINT
;
175 return parent
::getTask($value);