translate more strings
[civicrm-core.git] / CRM / Grant / Task.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2018
32 * $Id$
33 *
34 */
35
36 /**
37 * class to represent the actions that can be performed on a group of contacts
38 * used by the search forms
39 *
40 */
41 class CRM_Grant_Task extends CRM_Core_Task {
42
43 const
44 // Grant Tasks
45 UPDATE_GRANTS = 701;
46
47 static $objectType = 'grant';
48
49 /**
50 * These tasks are the core set of tasks that the user can perform
51 * on a contact / group of contacts
52 *
53 * @return array
54 * the set of tasks for a group of contacts
55 */
56 public static function tasks() {
57 if (!(self::$_tasks)) {
58 self::$_tasks = array(
59 self::TASK_DELETE => array(
60 'title' => ts('Delete grants'),
61 'class' => 'CRM_Grant_Form_Task_Delete',
62 'result' => FALSE,
63 ),
64 self::TASK_PRINT => array(
65 'title' => ts('Print selected rows'),
66 'class' => 'CRM_Grant_Form_Task_Print',
67 'result' => FALSE,
68 ),
69 self::TASK_EXPORT => array(
70 'title' => ts('Export grants'),
71 'class' => array(
72 'CRM_Export_Form_Select',
73 'CRM_Export_Form_Map',
74 ),
75 'result' => FALSE,
76 ),
77 self::UPDATE_GRANTS => array(
78 'title' => ts('Update grants'),
79 'class' => 'CRM_Grant_Form_Task_Update',
80 'result' => FALSE,
81 ),
82 );
83
84 if (!CRM_Core_Permission::check('delete in CiviGrant')) {
85 unset(self::$_tasks[self::TASK_DELETE]);
86 }
87
88 parent::tasks();
89 }
90
91 return self::$_tasks;
92 }
93
94 /**
95 * Show tasks selectively based on the permission level
96 * of the user
97 *
98 * @param int $permission
99 * @param array $params
100 *
101 * @return array
102 * set of tasks that are valid for the user
103 */
104 public static function permissionedTaskTitles($permission, $params = array()) {
105 if (($permission == CRM_Core_Permission::EDIT)
106 || CRM_Core_Permission::check('edit grants')
107 ) {
108 $tasks = self::taskTitles();
109 }
110 else {
111 $tasks = array(
112 self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'],
113 );
114 //CRM-4418,
115 if (CRM_Core_Permission::check('delete in CiviGrant')) {
116 $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title'];
117 }
118 }
119
120 $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params);
121 return $tasks;
122 }
123
124 /**
125 * These tasks are the core set of tasks that the user can perform
126 *
127 * @param int $value
128 *
129 * @return array
130 * the set of tasks for a group of contacts
131 */
132 public static function getTask($value) {
133 self::tasks();
134
135 if (!CRM_Utils_Array::value($value, self::$_tasks)) {
136 // make it the print task by default
137 $value = self::TASK_PRINT;
138 }
139 return parent::getTask($value);
140 }
141
142 }