Set version to 5.13.beta1
[civicrm-core.git] / CRM / Case / Task.php
CommitLineData
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 |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
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 |
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
6b83d5bd 31 * @copyright CiviCRM LLC (c) 2004-2019
6a488035
TO
32 */
33
34/**
67d19299 35 * Class to represent the actions that can be performed on a group of contacts.
6a488035 36 *
67d19299 37 * Used by the search forms
6a488035 38 */
047838bc 39class CRM_Case_Task extends CRM_Core_Task {
6a488035 40
047838bc
MW
41 const
42 // Case tasks
43 RESTORE_CASES = 501;
6a488035 44
047838bc 45 static $objectType = 'case';
6a488035
TO
46
47 /**
48 * These tasks are the core set of tasks that the user can perform
49 * on a contact / group of contacts
50 *
a6c01b45
CW
51 * @return array
52 * the set of tasks for a group of contacts
6a488035 53 */
047838bc 54 public static function tasks() {
6a488035 55 if (!self::$_tasks) {
be2fb01f
CW
56 self::$_tasks = [
57 self::TASK_DELETE => [
7f82e636 58 'title' => ts('Delete cases'),
6a488035
TO
59 'class' => 'CRM_Case_Form_Task_Delete',
60 'result' => FALSE,
be2fb01f
CW
61 ],
62 self::TASK_PRINT => [
7f82e636 63 'title' => ts('Print selected rows'),
6a488035
TO
64 'class' => 'CRM_Case_Form_Task_Print',
65 'result' => FALSE,
be2fb01f
CW
66 ],
67 self::TASK_EXPORT => [
7f82e636 68 'title' => ts('Export cases'),
be2fb01f 69 'class' => [
d5fd18f6 70 'CRM_Export_Form_Select_Case',
6a488035 71 'CRM_Export_Form_Map',
be2fb01f 72 ],
6a488035 73 'result' => FALSE,
be2fb01f
CW
74 ],
75 self::RESTORE_CASES => [
7f82e636 76 'title' => ts('Restore cases'),
6a488035
TO
77 'class' => 'CRM_Case_Form_Task_Restore',
78 'result' => FALSE,
be2fb01f
CW
79 ],
80 self::PDF_LETTER => [
d85976d8 81 'title' => ts('Print/merge document'),
13e6f3e9 82 'class' => 'CRM_Case_Form_Task_PDF',
8ffa3b7c 83 'result' => FALSE,
be2fb01f
CW
84 ],
85 self::BATCH_UPDATE => [
888da08c 86 'title' => ts('Update multiple cases'),
be2fb01f 87 'class' => [
888da08c
MW
88 'CRM_Case_Form_Task_PickProfile',
89 'CRM_Case_Form_Task_Batch',
be2fb01f 90 ],
888da08c 91 'result' => FALSE,
be2fb01f
CW
92 ],
93 ];
4d73a5a7 94
6a488035
TO
95 //CRM-4418, check for delete
96 if (!CRM_Core_Permission::check('delete in CiviCase')) {
047838bc 97 unset(self::$_tasks[self::TASK_DELETE]);
6a488035 98 }
4d73a5a7 99
047838bc 100 parent::tasks();
6a488035
TO
101 }
102
6a488035
TO
103 return self::$_tasks;
104 }
105
6a488035 106 /**
fe482240 107 * Show tasks selectively based on the permission level.
6a488035
TO
108 * of the user
109 *
110 * @param int $permission
047838bc 111 * @param array $params
6a488035 112 *
a6c01b45
CW
113 * @return array
114 * set of tasks that are valid for the user
6a488035 115 */
be2fb01f 116 public static function permissionedTaskTitles($permission, $params = []) {
6a488035
TO
117 if (($permission == CRM_Core_Permission::EDIT)
118 || CRM_Core_Permission::check('access all cases and activities')
119 || CRM_Core_Permission::check('access my cases and activities')
120 ) {
121 $tasks = self::taskTitles();
122 }
123 else {
be2fb01f 124 $tasks = [
047838bc 125 self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'],
be2fb01f 126 ];
6a488035
TO
127 //CRM-4418,
128 if (CRM_Core_Permission::check('delete in CiviCase')) {
047838bc 129 $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title'];
6a488035
TO
130 }
131 }
047838bc
MW
132
133 $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params);
6a488035
TO
134 return $tasks;
135 }
136
137 /**
fe482240 138 * These tasks are the core set of tasks.
6a488035
TO
139 *
140 * @param int $value
141 *
a6c01b45
CW
142 * @return array
143 * the set of tasks for a group of contacts
6a488035 144 */
00be9182 145 public static function getTask($value) {
6a488035
TO
146 self::tasks();
147 if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
148 // make the print task by default
047838bc 149 $value = self::TASK_PRINT;
6a488035
TO
150 }
151
be2fb01f 152 return [
6a488035
TO
153 self::$_tasks[$value]['class'],
154 self::$_tasks[$value]['result'],
be2fb01f 155 ];
6a488035 156 }
96025800 157
6a488035 158}