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 +--------------------------------------------------------------------+
30 * @copyright CiviCRM LLC (c) 2004-2018
34 * Class to represent the actions that can be performed on a group of contacts used by the search forms.
36 class CRM_Activity_Task
extends CRM_Core_Task
{
38 static $objectType = 'activity';
41 * These tasks are the core set of tasks that the user can perform
42 * on a contact / group of contacts.
45 * the set of tasks for a group of contacts
47 public static function tasks() {
48 if (!(self
::$_tasks)) {
49 self
::$_tasks = array(
50 self
::TASK_DELETE
=> array(
51 'title' => ts('Delete activities'),
52 'class' => 'CRM_Activity_Form_Task_Delete',
55 self
::TASK_PRINT
=> array(
56 'title' => ts('Print selected rows'),
57 'class' => 'CRM_Activity_Form_Task_Print',
60 self
::TASK_EXPORT
=> array(
61 'title' => ts('Export activities'),
63 'CRM_Export_Form_Select',
64 'CRM_Export_Form_Map',
68 self
::BATCH_UPDATE
=> array(
69 'title' => ts('Update multiple activities'),
71 'CRM_Activity_Form_Task_PickProfile',
72 'CRM_Activity_Form_Task_Batch',
76 self
::TASK_EMAIL
=> array(
77 'title' => ts('Email - send now (to %1 or less)', array(
79 ->get('simple_mail_limit'),
82 'CRM_Activity_Form_Task_PickOption',
83 'CRM_Activity_Form_Task_Email',
87 self
::TASK_SMS
=> array(
88 'title' => ts('SMS - send reply'),
89 'class' => 'CRM_Activity_Form_Task_SMS',
92 self
::TAG_ADD
=> array(
93 'title' => ts('Tag - add to activities'),
94 'class' => 'CRM_Activity_Form_Task_AddToTag',
97 self
::TAG_REMOVE
=> array(
98 'title' => ts('Tag - remove from activities'),
99 'class' => 'CRM_Activity_Form_Task_RemoveFromTag',
104 $config = CRM_Core_Config
::singleton();
105 if (in_array('CiviCase', $config->enableComponents
)) {
106 if (CRM_Core_Permission
::check('access all cases and activities') ||
107 CRM_Core_Permission
::check('access my cases and activities')
109 self
::$_tasks[self
::TASK_SMS
] = array(
110 'title' => ts('File on case'),
111 'class' => 'CRM_Activity_Form_Task_FileOnCase',
117 // CRM-4418, check for delete
118 if (!CRM_Core_Permission
::check('delete activities')) {
119 unset(self
::$_tasks[self
::TASK_DELETE
]);
125 return self
::$_tasks;
129 * Show tasks selectively based on the permission level of the user.
131 * @param int $permission
132 * @param array $params
135 * set of tasks that are valid for the user
137 public static function permissionedTaskTitles($permission, $params = array()) {
138 if ($permission == CRM_Core_Permission
::EDIT
) {
139 $tasks = self
::taskTitles();
143 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
147 if (CRM_Core_Permission
::check('delete activities')) {
148 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
152 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
157 * These tasks are the core set of tasks that the user can perform on activity.
162 * the set of tasks for a group of activity
164 public static function getTask($value) {
166 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
167 // make the print task by default
168 $value = self
::TASK_PRINT
;
172 self
::$_tasks[$value]['class'],
173 self
::$_tasks[$value]['result'],