3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
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
{
47 static $objectType = 'membership';
50 * These tasks are the core set of tasks that the user can perform
51 * on a contact / group of contacts
54 * the set of tasks for a group of contacts
56 public static function tasks() {
58 self
::$_tasks = array(
59 self
::TASK_DELETE
=> array(
60 'title' => ts('Delete memberships'),
61 'class' => 'CRM_Member_Form_Task_Delete',
64 self
::TASK_PRINT
=> array(
65 'title' => ts('Print selected rows'),
66 'class' => 'CRM_Member_Form_Task_Print',
69 self
::TASK_EXPORT
=> array(
70 'title' => ts('Export members'),
72 'CRM_Export_Form_Select',
73 'CRM_Export_Form_Map',
77 self
::TASK_EMAIL
=> array(
78 'title' => ts('Email - send now (to %1 or less)', array(
80 ->get('simple_mail_limit'),
82 'class' => 'CRM_Member_Form_Task_Email',
85 self
::BATCH_UPDATE
=> array(
86 'title' => ts('Update multiple memberships'),
88 'CRM_Member_Form_Task_PickProfile',
89 'CRM_Member_Form_Task_Batch',
93 self
::LABEL_MEMBERS
=> array(
94 'title' => ts('Mailing labels - print'),
96 'CRM_Member_Form_Task_Label',
100 self
::PDF_LETTER
=> array(
101 'title' => ts('Print/merge document for memberships'),
102 'class' => 'CRM_Member_Form_Task_PDFLetter',
105 self
::SAVE_SEARCH
=> array(
106 'title' => ts('Group - create smart group'),
107 'class' => 'CRM_Contact_Form_Task_SaveSearch',
110 self
::SAVE_SEARCH_UPDATE
=> array(
111 'title' => ts('Group - update smart group'),
112 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update',
117 //CRM-4418, check for delete
118 if (!CRM_Core_Permission
::check('delete in CiviMember')) {
119 unset(self
::$_tasks[self
::TASK_DELETE
]);
121 //CRM-12920 - check for edit permission
122 if (!CRM_Core_Permission
::check('edit memberships')) {
123 unset(self
::$_tasks[self
::BATCH_UPDATE
]);
129 return self
::$_tasks;
133 * These tasks are the core set of task titles
137 * the set of task titles
139 public static function taskTitles() {
140 return parent
::taskTitles();
144 * Show tasks selectively based on the permission level
147 * @param int $permission
148 * @param array $params
151 * set of tasks that are valid for the user
153 public static function permissionedTaskTitles($permission, $params = array()) {
154 if (($permission == CRM_Core_Permission
::EDIT
)
155 || CRM_Core_Permission
::check('edit memberships')
157 $tasks = self
::taskTitles();
161 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
162 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
165 if (CRM_Core_Permission
::check('delete in CiviMember')) {
166 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
170 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
175 * These tasks are the core set of tasks that the user can perform
181 * the set of tasks for a group of members
183 public static function getTask($value) {
185 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
186 // Make the print task the default
187 $value = self
::TASK_PRINT
;
189 return parent
::getTask($value);