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