Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
c73475ea | 12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
6a488035 TO |
13 | | | |
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. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
c73475ea WA |
20 | | License and the CiviCRM Licensing Exception along | |
21 | | with this program; if not, contact CiviCRM LLC | | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
6a488035 | 29 | * @package CRM |
6b83d5bd | 30 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
31 | */ |
32 | ||
33 | /** | |
3819f101 | 34 | * Class to represent the actions that can be performed on a group of contacts used by the search forms. |
6a488035 | 35 | */ |
be509c11 | 36 | class CRM_Activity_Task extends CRM_Core_Task { |
6a488035 | 37 | |
be509c11 | 38 | static $objectType = 'activity'; |
6a488035 TO |
39 | |
40 | /** | |
7808aae6 SB |
41 | * These tasks are the core set of tasks that the user can perform |
42 | * on a contact / group of contacts. | |
6a488035 | 43 | * |
a6c01b45 CW |
44 | * @return array |
45 | * the set of tasks for a group of contacts | |
6a488035 | 46 | */ |
be509c11 | 47 | public static function tasks() { |
6a488035 TO |
48 | if (!(self::$_tasks)) { |
49 | self::$_tasks = array( | |
be509c11 | 50 | self::TASK_DELETE => array( |
7f82e636 | 51 | 'title' => ts('Delete activities'), |
6a488035 TO |
52 | 'class' => 'CRM_Activity_Form_Task_Delete', |
53 | 'result' => FALSE, | |
54 | ), | |
be509c11 | 55 | self::TASK_PRINT => array( |
7f82e636 | 56 | 'title' => ts('Print selected rows'), |
6a488035 TO |
57 | 'class' => 'CRM_Activity_Form_Task_Print', |
58 | 'result' => FALSE, | |
59 | ), | |
be509c11 | 60 | self::TASK_EXPORT => array( |
7f82e636 | 61 | 'title' => ts('Export activities'), |
6a488035 TO |
62 | 'class' => array( |
63 | 'CRM_Export_Form_Select', | |
64 | 'CRM_Export_Form_Map', | |
65 | ), | |
66 | 'result' => FALSE, | |
67 | ), | |
be509c11 | 68 | self::BATCH_UPDATE => array( |
b581842f | 69 | 'title' => ts('Update multiple activities'), |
6a488035 TO |
70 | 'class' => array( |
71 | 'CRM_Activity_Form_Task_PickProfile', | |
72 | 'CRM_Activity_Form_Task_Batch', | |
73 | ), | |
74 | 'result' => FALSE, | |
75 | ), | |
be509c11 | 76 | self::TASK_EMAIL => array( |
21d01648 MW |
77 | 'title' => ts('Email - send now (to %1 or less)', array( |
78 | 1 => Civi::settings() | |
79 | ->get('simple_mail_limit'), | |
80 | )), | |
6a488035 TO |
81 | 'class' => array( |
82 | 'CRM_Activity_Form_Task_PickOption', | |
83 | 'CRM_Activity_Form_Task_Email', | |
84 | ), | |
85 | 'result' => FALSE, | |
86 | ), | |
be509c11 | 87 | self::TASK_SMS => array( |
7f82e636 | 88 | 'title' => ts('SMS - send reply'), |
6a488035 TO |
89 | 'class' => 'CRM_Activity_Form_Task_SMS', |
90 | 'result' => FALSE, | |
91 | ), | |
be509c11 | 92 | self::TAG_ADD => array( |
7f82e636 | 93 | 'title' => ts('Tag - add to activities'), |
f70ca446 PN |
94 | 'class' => 'CRM_Activity_Form_Task_AddToTag', |
95 | 'result' => FALSE, | |
96 | ), | |
be509c11 | 97 | self::TAG_REMOVE => array( |
7f82e636 | 98 | 'title' => ts('Tag - remove from activities'), |
f70ca446 PN |
99 | 'class' => 'CRM_Activity_Form_Task_RemoveFromTag', |
100 | 'result' => FALSE, | |
101 | ), | |
6a488035 TO |
102 | ); |
103 | ||
104 | $config = CRM_Core_Config::singleton(); | |
105 | if (in_array('CiviCase', $config->enableComponents)) { | |
481a74f4 | 106 | if (CRM_Core_Permission::check('access all cases and activities') || |
353ffa53 TO |
107 | CRM_Core_Permission::check('access my cases and activities') |
108 | ) { | |
be509c11 | 109 | self::$_tasks[self::TASK_SMS] = array( |
7f82e636 | 110 | 'title' => ts('File on case'), |
bbfeec41 BS |
111 | 'class' => 'CRM_Activity_Form_Task_FileOnCase', |
112 | 'result' => FALSE, | |
113 | ); | |
114 | } | |
6a488035 TO |
115 | } |
116 | ||
7808aae6 | 117 | // CRM-4418, check for delete |
6a488035 | 118 | if (!CRM_Core_Permission::check('delete activities')) { |
be509c11 | 119 | unset(self::$_tasks[self::TASK_DELETE]); |
6a488035 | 120 | } |
4d73a5a7 | 121 | |
be509c11 | 122 | parent::tasks(); |
6a488035 | 123 | } |
4d73a5a7 | 124 | |
6a488035 TO |
125 | return self::$_tasks; |
126 | } | |
127 | ||
6a488035 | 128 | /** |
7808aae6 | 129 | * Show tasks selectively based on the permission level of the user. |
6a488035 TO |
130 | * |
131 | * @param int $permission | |
be509c11 | 132 | * @param array $params |
6a488035 | 133 | * |
a6c01b45 CW |
134 | * @return array |
135 | * set of tasks that are valid for the user | |
6a488035 | 136 | */ |
be509c11 | 137 | public static function permissionedTaskTitles($permission, $params = array()) { |
6a488035 TO |
138 | if ($permission == CRM_Core_Permission::EDIT) { |
139 | $tasks = self::taskTitles(); | |
140 | } | |
141 | else { | |
142 | $tasks = array( | |
be509c11 | 143 | self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], |
6a488035 TO |
144 | ); |
145 | ||
146 | //CRM-4418, | |
147 | if (CRM_Core_Permission::check('delete activities')) { | |
be509c11 | 148 | $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title']; |
6a488035 TO |
149 | } |
150 | } | |
be509c11 MW |
151 | |
152 | $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); | |
6a488035 TO |
153 | return $tasks; |
154 | } | |
155 | ||
156 | /** | |
7808aae6 | 157 | * These tasks are the core set of tasks that the user can perform on activity. |
6a488035 TO |
158 | * |
159 | * @param int $value | |
160 | * | |
a6c01b45 CW |
161 | * @return array |
162 | * the set of tasks for a group of activity | |
6a488035 | 163 | */ |
00be9182 | 164 | public static function getTask($value) { |
6a488035 TO |
165 | self::tasks(); |
166 | if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) { | |
167 | // make the print task by default | |
be509c11 | 168 | $value = self::TASK_PRINT; |
6a488035 | 169 | } |
be509c11 | 170 | |
6a488035 TO |
171 | return array( |
172 | self::$_tasks[$value]['class'], | |
173 | self::$_tasks[$value]['result'], | |
174 | ); | |
175 | } | |
96025800 | 176 | |
6a488035 | 177 | } |