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