3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
35 * Class to represent the actions that can be performed on a group of contacts.
37 * Used by the search forms
39 class CRM_Case_Task
extends CRM_Core_Task
{
44 const RESTORE_CASES
= 501;
49 public static $objectType = 'case';
52 * These tasks are the core set of tasks that the user can perform
53 * on a contact / group of contacts
56 * the set of tasks for a group of contacts
58 public static function tasks() {
61 self
::TASK_DELETE
=> [
62 'title' => ts('Delete cases'),
63 'class' => 'CRM_Case_Form_Task_Delete',
67 'title' => ts('Print selected rows'),
68 'class' => 'CRM_Case_Form_Task_Print',
71 self
::TASK_EXPORT
=> [
72 'title' => ts('Export cases'),
74 'CRM_Export_Form_Select_Case',
75 'CRM_Export_Form_Map',
79 self
::RESTORE_CASES
=> [
80 'title' => ts('Restore cases'),
81 'class' => 'CRM_Case_Form_Task_Restore',
85 'title' => ts('Print/merge document'),
86 'class' => 'CRM_Case_Form_Task_PDF',
89 self
::BATCH_UPDATE
=> [
90 'title' => ts('Update multiple cases'),
92 'CRM_Case_Form_Task_PickProfile',
93 'CRM_Case_Form_Task_Batch',
99 //CRM-4418, check for delete
100 if (!CRM_Core_Permission
::check('delete in CiviCase')) {
101 unset(self
::$_tasks[self
::TASK_DELETE
]);
107 return self
::$_tasks;
111 * Show tasks selectively based on the permission level.
114 * @param int $permission
115 * @param array $params
118 * set of tasks that are valid for the user
120 public static function permissionedTaskTitles($permission, $params = []) {
121 if (($permission == CRM_Core_Permission
::EDIT
)
122 || CRM_Core_Permission
::check('access all cases and activities')
123 || CRM_Core_Permission
::check('access my cases and activities')
125 $tasks = self
::taskTitles();
129 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
132 if (CRM_Core_Permission
::check('delete in CiviCase')) {
133 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
137 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
142 * These tasks are the core set of tasks.
147 * the set of tasks for a group of contacts
149 public static function getTask($value) {
151 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
152 // make the print task by default
153 $value = self
::TASK_PRINT
;
157 self
::$_tasks[$value]['class'],
158 self
::$_tasks[$value]['result'],