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
19 * class to represent the actions that can be performed on a group of contacts
20 * used by the search forms
23 class CRM_Grant_Task
extends CRM_Core_Task
{
28 const UPDATE_GRANTS
= 701;
33 public static $objectType = 'grant';
36 * These tasks are the core set of tasks that the user can perform
37 * on a contact / group of contacts
40 * the set of tasks for a group of contacts
42 public static function tasks() {
43 if (!(self
::$_tasks)) {
45 self
::TASK_DELETE
=> [
46 'title' => ts('Delete grants'),
47 'class' => 'CRM_Grant_Form_Task_Delete',
51 'title' => ts('Print selected rows'),
52 'class' => 'CRM_Grant_Form_Task_Print',
55 self
::TASK_EXPORT
=> [
56 'title' => ts('Export grants'),
58 'CRM_Grant_Export_Form_Select',
59 'CRM_Grant_Export_Form_Map',
63 self
::UPDATE_GRANTS
=> [
64 'title' => ts('Update grants'),
65 'class' => 'CRM_Grant_Form_Task_Update',
70 if (!CRM_Core_Permission
::check('delete in CiviGrant')) {
71 unset(self
::$_tasks[self
::TASK_DELETE
]);
81 * Show tasks selectively based on the permission level
84 * @param int $permission
85 * @param array $params
88 * set of tasks that are valid for the user
90 public static function permissionedTaskTitles($permission, $params = []) {
91 if (($permission == CRM_Core_Permission
::EDIT
)
92 || CRM_Core_Permission
::check('edit grants')
94 $tasks = self
::taskTitles();
98 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
101 if (CRM_Core_Permission
::check('delete in CiviGrant')) {
102 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
106 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
111 * These tasks are the core set of tasks that the user can perform
116 * the set of tasks for a group of contacts
118 public static function getTask($value) {
121 if (empty(self
::$_tasks[$value])) {
122 // make it the print task by default
123 $value = self
::TASK_PRINT
;
125 return parent
::getTask($value);