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