3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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
{
43 const DELETE_MEMBERS
= 1, PRINT_MEMBERS
= 2, EXPORT_MEMBERS
= 3, EMAIL_CONTACTS
= 4, BATCH_MEMBERS
= 5;
50 static $_tasks = NULL;
53 * The optional task array
57 static $_optionalTasks = NULL;
60 * These tasks are the core set of tasks that the user can perform
61 * on a contact / group of contacts
64 * the set of tasks for a group of contacts
66 public static function &tasks() {
67 if (!(self
::$_tasks)) {
68 self
::$_tasks = array(
70 'title' => ts('Delete memberships'),
71 'class' => 'CRM_Member_Form_Task_Delete',
75 'title' => ts('Print selected rows'),
76 'class' => 'CRM_Member_Form_Task_Print',
80 'title' => ts('Export members'),
82 'CRM_Export_Form_Select',
83 'CRM_Export_Form_Map',
88 'title' => ts('Email - send now (to %1 or less)', array(
90 ->get('simple_mail_limit'),
92 'class' => 'CRM_Member_Form_Task_Email',
96 'title' => ts('Update multiple memberships'),
98 'CRM_Member_Form_Task_PickProfile',
99 'CRM_Member_Form_Task_Batch',
104 'title' => ts('Mailing labels - print'),
106 'CRM_Member_Form_Task_Label',
111 'title' => ts('Print/merge document for memberships'),
112 'class' => 'CRM_Member_Form_Task_PDFLetter',
117 //CRM-4418, check for delete
118 if (!CRM_Core_Permission
::check('delete in CiviMember')) {
119 unset(self
::$_tasks[1]);
121 //CRM-12920 - check for edit permission
122 if (!CRM_Core_Permission
::check('edit memberships')) {
123 unset(self
::$_tasks[5]);
126 CRM_Utils_Hook
::searchTasks('membership', self
::$_tasks);
127 asort(self
::$_tasks);
130 return self
::$_tasks;
134 * These tasks are the core set of task titles
138 * the set of task titles
140 public static function &taskTitles() {
143 foreach (self
::$_tasks as $id => $value) {
144 $titles[$id] = $value['title'];
150 * Show tasks selectively based on the permission level
153 * @param int $permission
156 * set of tasks that are valid for the user
158 public static function &permissionedTaskTitles($permission) {
160 if (($permission == CRM_Core_Permission
::EDIT
)
161 || CRM_Core_Permission
::check('edit memberships')
163 $tasks = self
::taskTitles();
167 3 => self
::$_tasks[3]['title'],
168 4 => self
::$_tasks[4]['title'],
171 if (CRM_Core_Permission
::check('delete in CiviMember')) {
172 $tasks[1] = self
::$_tasks[1]['title'];
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 by default
194 self
::$_tasks[$value]['class'],
195 self
::$_tasks[$value]['result'],