Commit | Line | Data |
---|---|---|
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 | */ |
36 | class CRM_Pledge_Info extends CRM_Core_Component_Info { | |
37 | ||
e7c15cb6 | 38 | /** |
c86d4e7c | 39 | * @var string |
d7923f9a | 40 | * @inheritDoc |
e7c15cb6 | 41 | */ |
6a488035 TO |
42 | protected $keyword = 'pledge'; |
43 | ||
ffd93213 EM |
44 | /** |
45 | * Provides base information about the component. | |
46 | * Needs to be implemented in component's information | |
47 | * class. | |
48 | * | |
a6c01b45 CW |
49 | * @return array |
50 | * collection of required component settings | |
ffd93213 | 51 | */ |
6a488035 | 52 | public function getInfo() { |
be2fb01f | 53 | return [ |
6a488035 TO |
54 | 'name' => 'CiviPledge', |
55 | 'translatedName' => ts('CiviPledge'), | |
56 | 'title' => ts('CiviCRM Pledge Engine'), | |
57 | 'search' => 1, | |
58 | 'showActivitiesInCore' => 1, | |
be2fb01f | 59 | ]; |
6a488035 TO |
60 | } |
61 | ||
ffd93213 | 62 | /** |
d7923f9a | 63 | * @inheritDoc |
ffd93213 EM |
64 | * Provides permissions that are used by component. |
65 | * Needs to be implemented in component's information | |
66 | * class. | |
67 | * | |
68 | * NOTE: if using conditionally permission return, | |
69 | * implementation of $getAllUnconditionally is required. | |
70 | * | |
71 | * @param bool $getAllUnconditionally | |
221b21b4 AH |
72 | * @param bool $descriptions |
73 | * Whether to return permission descriptions | |
ffd93213 | 74 | * |
72b3a70c CW |
75 | * @return array|null |
76 | * collection of permissions, null if none | |
ffd93213 | 77 | */ |
221b21b4 | 78 | public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { |
be2fb01f CW |
79 | $permissions = [ |
80 | 'access CiviPledge' => [ | |
221b21b4 AH |
81 | ts('access CiviPledge'), |
82 | ts('View pledges'), | |
be2fb01f CW |
83 | ], |
84 | 'edit pledges' => [ | |
221b21b4 AH |
85 | ts('edit pledges'), |
86 | ts('Create and update pledges'), | |
be2fb01f CW |
87 | ], |
88 | 'delete in CiviPledge' => [ | |
221b21b4 AH |
89 | ts('delete in CiviPledge'), |
90 | ts('Delete pledges'), | |
be2fb01f CW |
91 | ], |
92 | ]; | |
221b21b4 AH |
93 | |
94 | if (!$descriptions) { | |
95 | foreach ($permissions as $name => $attr) { | |
96 | $permissions[$name] = array_shift($attr); | |
97 | } | |
98 | } | |
99 | ||
100 | return $permissions; | |
6a488035 TO |
101 | } |
102 | ||
ffd93213 | 103 | /** |
d7923f9a | 104 | * @inheritDoc |
ffd93213 EM |
105 | * Provides information about user dashboard element |
106 | * offered by this component. | |
107 | * | |
72b3a70c CW |
108 | * @return array|null |
109 | * collection of required dashboard settings, | |
ffd93213 | 110 | * null if no element offered |
ffd93213 | 111 | */ |
6a488035 | 112 | public function getUserDashboardElement() { |
be2fb01f | 113 | return [ |
353ffa53 | 114 | 'name' => ts('Pledges'), |
6a488035 TO |
115 | 'title' => ts('Your Pledge(s)'), |
116 | // we need to check this permission since you can click on contribution page link for making payment | |
be2fb01f | 117 | 'perm' => ['make online contributions'], |
6a488035 | 118 | 'weight' => 15, |
be2fb01f | 119 | ]; |
6a488035 TO |
120 | } |
121 | ||
ffd93213 | 122 | /** |
d7923f9a | 123 | * @inheritDoc |
ffd93213 EM |
124 | * Provides information about user dashboard element |
125 | * offered by this component. | |
126 | * | |
72b3a70c CW |
127 | * @return array|null |
128 | * collection of required dashboard settings, | |
ffd93213 | 129 | * null if no element offered |
ffd93213 | 130 | */ |
6a488035 | 131 | public function registerTab() { |
be2fb01f | 132 | return [ |
353ffa53 | 133 | 'title' => ts('Pledges'), |
6a488035 TO |
134 | 'url' => 'pledge', |
135 | 'weight' => 25, | |
be2fb01f | 136 | ]; |
6a488035 TO |
137 | } |
138 | ||
b04115b4 CW |
139 | /** |
140 | * @inheritDoc | |
141 | * @return string | |
142 | */ | |
143 | public function getIcon() { | |
144 | return 'crm-i fa-paper-plane'; | |
145 | } | |
146 | ||
ffd93213 | 147 | /** |
d7923f9a | 148 | * @inheritDoc |
ffd93213 EM |
149 | * Provides information about advanced search pane |
150 | * offered by this component. | |
151 | * | |
72b3a70c CW |
152 | * @return array|null |
153 | * collection of required pane settings, | |
ffd93213 | 154 | * null if no element offered |
ffd93213 | 155 | */ |
6a488035 | 156 | public function registerAdvancedSearchPane() { |
be2fb01f | 157 | return [ |
353ffa53 | 158 | 'title' => ts('Pledges'), |
6a488035 | 159 | 'weight' => 25, |
be2fb01f | 160 | ]; |
6a488035 TO |
161 | } |
162 | ||
ffd93213 | 163 | /** |
d7923f9a | 164 | * @inheritDoc |
ffd93213 EM |
165 | * Provides potential activity types that this |
166 | * component might want to register in activity history. | |
167 | * Needs to be implemented in component's information | |
168 | * class. | |
169 | * | |
72b3a70c CW |
170 | * @return array|null |
171 | * collection of activity types | |
ffd93213 | 172 | */ |
6a488035 TO |
173 | public function getActivityTypes() { |
174 | return NULL; | |
175 | } | |
176 | ||
ffd93213 | 177 | /** |
fe482240 | 178 | * add shortcut to Create New. |
ffd93213 EM |
179 | * @param $shortCuts |
180 | */ | |
6a488035 TO |
181 | public function creatNewShortcut(&$shortCuts) { |
182 | if (CRM_Core_Permission::check('access CiviPledge') && | |
183 | CRM_Core_Permission::check('edit pledges') | |
184 | ) { | |
be2fb01f CW |
185 | $shortCuts = array_merge($shortCuts, [ |
186 | [ | |
353ffa53 TO |
187 | 'path' => 'civicrm/pledge/add', |
188 | 'query' => 'reset=1&action=add&context=standalone', | |
189 | 'ref' => 'new-pledge', | |
190 | 'title' => ts('Pledge'), | |
be2fb01f CW |
191 | ], |
192 | ]); | |
6a488035 TO |
193 | } |
194 | } | |
96025800 | 195 | |
6a488035 | 196 | } |