Remove call to deprecated function
[civicrm-core.git] / CRM / Activity / Task.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * @package CRM
14 * @copyright CiviCRM LLC https://civicrm.org/licensing
15 */
16
17 /**
18 * Class to represent the actions that can be performed on a group of contacts used by the search forms.
19 */
20 class CRM_Activity_Task extends CRM_Core_Task {
21
22 public static $objectType = 'activity';
23
24 /**
25 * These tasks are the core set of tasks that the user can perform
26 * on a contact / group of contacts.
27 *
28 * @return array
29 * the set of tasks for a group of contacts
30 */
31 public static function tasks() {
32 if (!(self::$_tasks)) {
33 self::$_tasks = [
34 self::TASK_DELETE => [
35 'title' => ts('Delete activities'),
36 'class' => 'CRM_Activity_Form_Task_Delete',
37 'result' => FALSE,
38 ],
39 self::TASK_PRINT => [
40 'title' => ts('Print selected rows'),
41 'class' => 'CRM_Activity_Form_Task_Print',
42 'result' => FALSE,
43 ],
44 self::TASK_EXPORT => [
45 'title' => ts('Export activities'),
46 'class' => [
47 'CRM_Activity_Export_Form_Select',
48 'CRM_Activity_Export_Form_Map',
49 ],
50 'result' => FALSE,
51 ],
52 self::BATCH_UPDATE => [
53 'title' => ts('Update multiple activities'),
54 'class' => [
55 'CRM_Activity_Form_Task_PickProfile',
56 'CRM_Activity_Form_Task_Batch',
57 ],
58 'result' => FALSE,
59 ],
60 self::TASK_EMAIL => [
61 'title' => ts('Email - send now (to %1 or less)', [
62 1 => Civi::settings()
63 ->get('simple_mail_limit'),
64 ]),
65 'class' => [
66 'CRM_Activity_Form_Task_PickOption',
67 'CRM_Activity_Form_Task_Email',
68 ],
69 'result' => FALSE,
70 ],
71 self::PDF_LETTER => [
72 'title' => ts('Print/merge Document'),
73 'class' => 'CRM_Activity_Form_Task_PDF',
74 'result' => FALSE,
75 ],
76 self::TASK_SMS => [
77 'title' => ts('SMS - send reply'),
78 'class' => 'CRM_Activity_Form_Task_SMS',
79 'result' => FALSE,
80 ],
81 self::TAG_ADD => [
82 'title' => ts('Tag - add to activities'),
83 'class' => 'CRM_Activity_Form_Task_AddToTag',
84 'result' => FALSE,
85 ],
86 self::TAG_REMOVE => [
87 'title' => ts('Tag - remove from activities'),
88 'class' => 'CRM_Activity_Form_Task_RemoveFromTag',
89 'result' => FALSE,
90 ],
91 ];
92
93 if (CRM_Core_Component::isEnabled('CiviCase')) {
94 if (CRM_Core_Permission::check('access all cases and activities') ||
95 CRM_Core_Permission::check('access my cases and activities')
96 ) {
97 self::$_tasks[self::TASK_SMS] = [
98 'title' => ts('File on case'),
99 'class' => 'CRM_Activity_Form_Task_FileOnCase',
100 'result' => FALSE,
101 ];
102 }
103 }
104
105 // CRM-4418, check for delete
106 if (!CRM_Core_Permission::check('delete activities')) {
107 unset(self::$_tasks[self::TASK_DELETE]);
108 }
109
110 parent::tasks();
111 }
112
113 return self::$_tasks;
114 }
115
116 /**
117 * Show tasks selectively based on the permission level of the user.
118 *
119 * @param int $permission
120 * @param array $params
121 *
122 * @return array
123 * set of tasks that are valid for the user
124 */
125 public static function permissionedTaskTitles($permission, $params = []) {
126 if ($permission == CRM_Core_Permission::EDIT) {
127 $tasks = self::taskTitles();
128 }
129 else {
130 $tasks = [
131 self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'],
132 ];
133
134 //CRM-4418,
135 if (CRM_Core_Permission::check('delete activities')) {
136 $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title'];
137 }
138 }
139
140 $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params);
141 return $tasks;
142 }
143
144 /**
145 * These tasks are the core set of tasks that the user can perform on activity.
146 *
147 * @param int $value
148 *
149 * @return array
150 * the set of tasks for a group of activity
151 */
152 public static function getTask($value) {
153 self::tasks();
154 if (!$value || empty(self::$_tasks[$value])) {
155 // make the print task by default
156 $value = self::TASK_PRINT;
157 }
158 if (isset(self::$_tasks[$value])) {
159 return [(array) self::$_tasks[$value]['class'], self::$_tasks[$value]['result']];
160 }
161 return [[], NULL];
162 }
163
164 }