3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
37 * class to represent the actions that can be performed on a group of
38 * contacts (CiviMember)
39 * used by the search forms
42 class CRM_Member_Task
extends CRM_Core_Task
{
46 const LABEL_MEMBERS
= 201;
51 public static $objectType = 'membership';
54 * These tasks are the core set of tasks that the user can perform
55 * on a contact / group of contacts
58 * the set of tasks for a group of contacts
60 public static function tasks() {
63 self
::TASK_DELETE
=> [
64 'title' => ts('Delete memberships'),
65 'class' => 'CRM_Member_Form_Task_Delete',
69 'title' => ts('Print selected rows'),
70 'class' => 'CRM_Member_Form_Task_Print',
73 self
::TASK_EXPORT
=> [
74 'title' => ts('Export members'),
76 'CRM_Export_Form_Select',
77 'CRM_Export_Form_Map',
82 'title' => ts('Email - send now (to %1 or less)', [
84 ->get('simple_mail_limit'),
86 'class' => 'CRM_Member_Form_Task_Email',
89 self
::BATCH_UPDATE
=> [
90 'title' => ts('Update multiple memberships'),
92 'CRM_Member_Form_Task_PickProfile',
93 'CRM_Member_Form_Task_Batch',
97 self
::LABEL_MEMBERS
=> [
98 'title' => ts('Mailing labels - print'),
100 'CRM_Member_Form_Task_Label',
104 self
::PDF_LETTER
=> [
105 'title' => ts('Print/merge document for memberships'),
106 'class' => 'CRM_Member_Form_Task_PDFLetter',
109 self
::SAVE_SEARCH
=> [
110 'title' => ts('Group - create smart group'),
111 'class' => 'CRM_Contact_Form_Task_SaveSearch',
114 self
::SAVE_SEARCH_UPDATE
=> [
115 'title' => ts('Group - update smart group'),
116 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update',
121 //CRM-4418, check for delete
122 if (!CRM_Core_Permission
::check('delete in CiviMember')) {
123 unset(self
::$_tasks[self
::TASK_DELETE
]);
125 //CRM-12920 - check for edit permission
126 if (!CRM_Core_Permission
::check('edit memberships')) {
127 unset(self
::$_tasks[self
::BATCH_UPDATE
]);
133 return self
::$_tasks;
137 * These tasks are the core set of task titles
141 * the set of task titles
143 public static function taskTitles() {
144 return parent
::taskTitles();
148 * Show tasks selectively based on the permission level
151 * @param int $permission
152 * @param array $params
155 * set of tasks that are valid for the user
157 public static function permissionedTaskTitles($permission, $params = []) {
158 if (($permission == CRM_Core_Permission
::EDIT
)
159 || CRM_Core_Permission
::check('edit memberships')
161 $tasks = self
::taskTitles();
165 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
166 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
169 if (CRM_Core_Permission
::check('delete in CiviMember')) {
170 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
174 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
179 * These tasks are the core set of tasks that the user can perform
185 * the set of tasks for a group of members
187 public static function getTask($value) {
189 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
190 // Make the print task the default
191 $value = self
::TASK_PRINT
;
193 return parent
::getTask($value);