Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
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 | |
8c9251b3 | 31 | * @copyright CiviCRM LLC (c) 2004-2018 |
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 | 39 | class 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 TO |
55 | if (!self::$_tasks) { |
56 | self::$_tasks = array( | |
047838bc | 57 | self::TASK_DELETE => array( |
7f82e636 | 58 | 'title' => ts('Delete cases'), |
6a488035 TO |
59 | 'class' => 'CRM_Case_Form_Task_Delete', |
60 | 'result' => FALSE, | |
61 | ), | |
047838bc | 62 | self::TASK_PRINT => array( |
7f82e636 | 63 | 'title' => ts('Print selected rows'), |
6a488035 TO |
64 | 'class' => 'CRM_Case_Form_Task_Print', |
65 | 'result' => FALSE, | |
66 | ), | |
047838bc | 67 | self::TASK_EXPORT => array( |
7f82e636 | 68 | 'title' => ts('Export cases'), |
6a488035 TO |
69 | 'class' => array( |
70 | 'CRM_Export_Form_Select', | |
71 | 'CRM_Export_Form_Map', | |
72 | ), | |
73 | 'result' => FALSE, | |
74 | ), | |
047838bc | 75 | self::RESTORE_CASES => array( |
7f82e636 | 76 | 'title' => ts('Restore cases'), |
6a488035 TO |
77 | 'class' => 'CRM_Case_Form_Task_Restore', |
78 | 'result' => FALSE, | |
79 | ), | |
047838bc | 80 | self::PDF_LETTER => array( |
dfb8b1ac | 81 | 'title' => ts('Print/merge Document'), |
13e6f3e9 | 82 | 'class' => 'CRM_Case_Form_Task_PDF', |
8ffa3b7c | 83 | 'result' => FALSE, |
84 | ), | |
047838bc | 85 | self::BATCH_UPDATE => array( |
888da08c MW |
86 | 'title' => ts('Update multiple cases'), |
87 | 'class' => array( | |
88 | 'CRM_Case_Form_Task_PickProfile', | |
89 | 'CRM_Case_Form_Task_Batch', | |
90 | ), | |
91 | 'result' => FALSE, | |
92 | ), | |
6a488035 | 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 | */ |
047838bc | 116 | public static function permissionedTaskTitles($permission, $params = array()) { |
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 { | |
124 | $tasks = array( | |
047838bc | 125 | self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], |
6a488035 TO |
126 | ); |
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 | ||
152 | return array( | |
153 | self::$_tasks[$value]['class'], | |
154 | self::$_tasks[$value]['result'], | |
155 | ); | |
156 | } | |
96025800 | 157 | |
6a488035 | 158 | } |