Merge pull request #16109 from seamuslee001/utils_grant_bin_fatal_exception
[civicrm-core.git] / CRM / Grant / Info.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * This class introduces component to the system and provides all the
14 * information about it. It needs to extend CRM_Core_Component_Info
15 * abstract class.
16 *
17 * @package CRM
18 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * $Id$
20 *
21 */
22 class CRM_Grant_Info extends CRM_Core_Component_Info {
23
24 /**
25 * @var string
26 * @inheritDoc
27 */
28 protected $keyword = 'grant';
29
30 /**
31 * @inheritDoc
32 * @return array
33 */
34 public function getInfo() {
35 return [
36 'name' => 'CiviGrant',
37 'translatedName' => ts('CiviGrant'),
38 'title' => 'CiviCRM Grant Management Engine',
39 'path' => 'CRM_Grant_',
40 'search' => 1,
41 'showActivitiesInCore' => 1,
42 ];
43 }
44
45 /**
46 * @inheritDoc
47 * @param bool $getAllUnconditionally
48 * @param bool $descriptions
49 * Whether to return permission descriptions
50 *
51 * @return array
52 */
53 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
54 $permissions = [
55 'access CiviGrant' => [
56 ts('access CiviGrant'),
57 ts('View all grants'),
58 ],
59 'edit grants' => [
60 ts('edit grants'),
61 ts('Create and update grants'),
62 ],
63 'delete in CiviGrant' => [
64 ts('delete in CiviGrant'),
65 ts('Delete grants'),
66 ],
67 ];
68
69 if (!$descriptions) {
70 foreach ($permissions as $name => $attr) {
71 $permissions[$name] = array_shift($attr);
72 }
73 }
74
75 return $permissions;
76 }
77
78 /**
79 * @inheritDoc
80 * @return null
81 */
82 public function getUserDashboardElement() {
83 // no dashboard element for this component
84 return NULL;
85 }
86
87 /**
88 * @inheritDoc
89 * @return null
90 */
91 public function getUserDashboardObject() {
92 // no dashboard element for this component
93 return NULL;
94 }
95
96 /**
97 * @inheritDoc
98 * @return array
99 */
100 public function registerTab() {
101 return [
102 'title' => ts('Grants'),
103 'url' => 'grant',
104 'weight' => 60,
105 ];
106 }
107
108 /**
109 * @inheritDoc
110 * @return string
111 */
112 public function getIcon() {
113 return 'crm-i fa-money';
114 }
115
116 /**
117 * @inheritDoc
118 * @return array
119 */
120 public function registerAdvancedSearchPane() {
121 return [
122 'title' => ts('Grants'),
123 'weight' => 50,
124 ];
125 }
126
127 /**
128 * @inheritDoc
129 * @return null
130 */
131 public function getActivityTypes() {
132 return NULL;
133 }
134
135 /**
136 * add shortcut to Create New.
137 * @param $shortCuts
138 */
139 public function creatNewShortcut(&$shortCuts) {
140 if (CRM_Core_Permission::check('access CiviGrant') &&
141 CRM_Core_Permission::check('edit grants')
142 ) {
143 $shortCuts = array_merge($shortCuts, [
144 [
145 'path' => 'civicrm/grant/add',
146 'query' => "reset=1&action=add&context=standalone",
147 'ref' => 'new-grant',
148 'title' => ts('Grant'),
149 ],
150 ]);
151 }
152 }
153
154 }