3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * class to represent the actions that can be performed on a group of contacts
22 * used by the search forms
25 class CRM_Grant_Task
extends CRM_Core_Task
{
30 const UPDATE_GRANTS
= 701;
35 public static $objectType = 'grant';
38 * These tasks are the core set of tasks that the user can perform
39 * on a contact / group of contacts
42 * the set of tasks for a group of contacts
44 public static function tasks() {
45 if (!(self
::$_tasks)) {
47 self
::TASK_DELETE
=> [
48 'title' => ts('Delete grants'),
49 'class' => 'CRM_Grant_Form_Task_Delete',
53 'title' => ts('Print selected rows'),
54 'class' => 'CRM_Grant_Form_Task_Print',
57 self
::TASK_EXPORT
=> [
58 'title' => ts('Export grants'),
60 'CRM_Export_Form_Select',
61 'CRM_Export_Form_Map',
65 self
::UPDATE_GRANTS
=> [
66 'title' => ts('Update grants'),
67 'class' => 'CRM_Grant_Form_Task_Update',
72 if (!CRM_Core_Permission
::check('delete in CiviGrant')) {
73 unset(self
::$_tasks[self
::TASK_DELETE
]);
83 * Show tasks selectively based on the permission level
86 * @param int $permission
87 * @param array $params
90 * set of tasks that are valid for the user
92 public static function permissionedTaskTitles($permission, $params = []) {
93 if (($permission == CRM_Core_Permission
::EDIT
)
94 || CRM_Core_Permission
::check('edit grants')
96 $tasks = self
::taskTitles();
100 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
103 if (CRM_Core_Permission
::check('delete in CiviGrant')) {
104 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
108 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
113 * These tasks are the core set of tasks that the user can perform
118 * the set of tasks for a group of contacts
120 public static function getTask($value) {
123 if (!CRM_Utils_Array
::value($value, self
::$_tasks)) {
124 // make it the print task by default
125 $value = self
::TASK_PRINT
;
127 return parent
::getTask($value);