3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
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;
51 static $_tasks = NULL;
54 * the optional task array
59 static $_optionalTasks = NULL;
62 * These tasks are the core set of tasks that the user can perform
63 * on a contact / group of contacts
65 * @return array the set of tasks for a group of contacts
69 static function &tasks() {
70 if (!(self
::$_tasks)) {
71 self
::$_tasks = array(
72 1 => array('title' => ts('Delete Members'),
73 'class' => 'CRM_Member_Form_Task_Delete',
76 2 => array('title' => ts('Print Memberships'),
77 'class' => 'CRM_Member_Form_Task_Print',
80 3 => array('title' => ts('Export Members'),
82 'CRM_Export_Form_Select',
83 'CRM_Export_Form_Map',
87 4 => array('title' => ts('Send Email to Contacts'),
88 'class' => 'CRM_Member_Form_Task_Email',
91 5 => array('title' => ts('Batch Update Members Via Profile'),
93 'CRM_Member_Form_Task_PickProfile',
94 'CRM_Member_Form_Task_Batch',
100 //CRM-4418, check for delete
101 if (!CRM_Core_Permission
::check('delete in CiviMember')) {
102 unset(self
::$_tasks[1]);
105 CRM_Utils_Hook
::searchTasks('membership', self
::$_tasks);
106 asort(self
::$_tasks);
107 return self
::$_tasks;
111 * These tasks are the core set of task titles
114 * @return array the set of task titles
118 static function &taskTitles() {
121 foreach (self
::$_tasks as $id => $value) {
122 // skip Print Membership task
124 $titles[$id] = $value['title'];
131 * show tasks selectively based on the permission level
134 * @param int $permission
136 * @return array set of tasks that are valid for the user
139 static function &permissionedTaskTitles($permission) {
141 if (($permission == CRM_Core_Permission
::EDIT
)
142 || CRM_Core_Permission
::check('edit memberships')
144 $tasks = self
::taskTitles();
148 3 => self
::$_tasks[3]['title'],
149 4 => self
::$_tasks[4]['title'],
152 if (CRM_Core_Permission
::check('delete in CiviMember')) {
153 $tasks[1] = self
::$_tasks[1]['title'];
160 * These tasks are the core set of tasks that the user can perform
165 * @return array the set of tasks for a group of members
169 static function getTask($value) {
171 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
172 // make the print task by default
176 self
::$_tasks[$value]['class'],
177 self
::$_tasks[$value]['result'],