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_Contribute_Info extends CRM_Core_Component_Info { | |
37 | ||
38 | ||
e7c15cb6 | 39 | /** |
1330f57a | 40 | * @var string |
e7c15cb6 CW |
41 | * @inheritDoc |
42 | */ | |
6a488035 TO |
43 | protected $keyword = 'contribute'; |
44 | ||
186c9c17 | 45 | /** |
e7c15cb6 | 46 | * @inheritDoc |
186c9c17 EM |
47 | * Provides base information about the component. |
48 | * Needs to be implemented in component's information | |
49 | * class. | |
50 | * | |
a6c01b45 CW |
51 | * @return array |
52 | * collection of required component settings | |
186c9c17 | 53 | */ |
1330f57a | 54 | |
186c9c17 EM |
55 | /** |
56 | * @return array | |
57 | */ | |
6a488035 | 58 | public function getInfo() { |
be2fb01f | 59 | return [ |
6a488035 TO |
60 | 'name' => 'CiviContribute', |
61 | 'translatedName' => ts('CiviContribute'), | |
62 | 'title' => ts('CiviCRM Contribution Engine'), | |
63 | 'search' => 1, | |
64 | 'showActivitiesInCore' => 1, | |
be2fb01f | 65 | ]; |
6a488035 TO |
66 | } |
67 | ||
186c9c17 | 68 | /** |
e7c15cb6 | 69 | * @inheritDoc |
186c9c17 EM |
70 | * Provides permissions that are used by component. |
71 | * Needs to be implemented in component's information | |
72 | * class. | |
73 | * | |
74 | * NOTE: if using conditionally permission return, | |
75 | * implementation of $getAllUnconditionally is required. | |
76 | * | |
77 | * @param bool $getAllUnconditionally | |
221b21b4 AH |
78 | * @param bool $descriptions |
79 | * Whether to return permission descriptions | |
186c9c17 | 80 | * |
72b3a70c CW |
81 | * @return array|null |
82 | * collection of permissions, null if none | |
186c9c17 | 83 | */ |
221b21b4 | 84 | public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { |
be2fb01f CW |
85 | $permissions = [ |
86 | 'access CiviContribute' => [ | |
221b21b4 AH |
87 | ts('access CiviContribute'), |
88 | ts('Record backend contributions (with edit contributions) and view all contributions (for visible contacts)'), | |
be2fb01f CW |
89 | ], |
90 | 'edit contributions' => [ | |
221b21b4 AH |
91 | ts('edit contributions'), |
92 | ts('Record and update contributions'), | |
be2fb01f CW |
93 | ], |
94 | 'make online contributions' => [ | |
221b21b4 | 95 | ts('make online contributions'), |
be2fb01f CW |
96 | ], |
97 | 'delete in CiviContribute' => [ | |
221b21b4 AH |
98 | ts('delete in CiviContribute'), |
99 | ts('Delete contributions'), | |
be2fb01f CW |
100 | ], |
101 | ]; | |
221b21b4 AH |
102 | |
103 | if (!$descriptions) { | |
104 | foreach ($permissions as $name => $attr) { | |
105 | $permissions[$name] = array_shift($attr); | |
106 | } | |
107 | } | |
108 | ||
109 | return $permissions; | |
6a488035 TO |
110 | } |
111 | ||
186c9c17 | 112 | /** |
fe482240 | 113 | * Provides permissions that are unwise for Anonymous Roles to have. |
186c9c17 | 114 | * |
a6c01b45 CW |
115 | * @return array |
116 | * list of permissions | |
186c9c17 EM |
117 | * @see CRM_Component_Info::getPermissions |
118 | */ | |
1330f57a | 119 | |
186c9c17 EM |
120 | /** |
121 | * @return array | |
122 | */ | |
81bb85ea | 123 | public function getAnonymousPermissionWarnings() { |
be2fb01f | 124 | return [ |
81bb85ea | 125 | 'access CiviContribute', |
be2fb01f | 126 | ]; |
81bb85ea | 127 | } |
6a488035 | 128 | |
186c9c17 | 129 | /** |
e7c15cb6 | 130 | * @inheritDoc |
186c9c17 EM |
131 | * Provides information about user dashboard element |
132 | * offered by this component. | |
133 | * | |
72b3a70c CW |
134 | * @return array|null |
135 | * collection of required dashboard settings, | |
186c9c17 | 136 | * null if no element offered |
186c9c17 | 137 | */ |
1330f57a | 138 | |
186c9c17 EM |
139 | /** |
140 | * @return array|null | |
141 | */ | |
6a488035 | 142 | public function getUserDashboardElement() { |
be2fb01f | 143 | return [ |
353ffa53 | 144 | 'name' => ts('Contributions'), |
6a488035 | 145 | 'title' => ts('Your Contribution(s)'), |
be2fb01f | 146 | 'perm' => ['make online contributions'], |
6a488035 | 147 | 'weight' => 10, |
be2fb01f | 148 | ]; |
6a488035 TO |
149 | } |
150 | ||
186c9c17 | 151 | /** |
e7c15cb6 | 152 | * @inheritDoc |
186c9c17 EM |
153 | * Provides information about user dashboard element |
154 | * offered by this component. | |
155 | * | |
72b3a70c CW |
156 | * @return array|null |
157 | * collection of required dashboard settings, | |
186c9c17 | 158 | * null if no element offered |
186c9c17 | 159 | */ |
1330f57a | 160 | |
186c9c17 EM |
161 | /** |
162 | * @return array|null | |
163 | */ | |
6a488035 | 164 | public function registerTab() { |
be2fb01f | 165 | return [ |
353ffa53 | 166 | 'title' => ts('Contributions'), |
6a488035 TO |
167 | 'url' => 'contribution', |
168 | 'weight' => 20, | |
be2fb01f | 169 | ]; |
6a488035 TO |
170 | } |
171 | ||
b04115b4 CW |
172 | /** |
173 | * @inheritDoc | |
174 | * @return string | |
175 | */ | |
176 | public function getIcon() { | |
177 | return 'crm-i fa-credit-card'; | |
178 | } | |
179 | ||
186c9c17 | 180 | /** |
e7c15cb6 | 181 | * @inheritDoc |
186c9c17 EM |
182 | * Provides information about advanced search pane |
183 | * offered by this component. | |
184 | * | |
72b3a70c CW |
185 | * @return array|null |
186 | * collection of required pane settings, | |
186c9c17 | 187 | * null if no element offered |
186c9c17 | 188 | */ |
1330f57a | 189 | |
186c9c17 EM |
190 | /** |
191 | * @return array|null | |
192 | */ | |
6a488035 | 193 | public function registerAdvancedSearchPane() { |
be2fb01f | 194 | return [ |
a91e698a | 195 | 'title' => ts('Contributions'), |
6a488035 | 196 | 'weight' => 20, |
be2fb01f | 197 | ]; |
6a488035 TO |
198 | } |
199 | ||
186c9c17 | 200 | /** |
e7c15cb6 | 201 | * @inheritDoc |
186c9c17 EM |
202 | * Provides potential activity types that this |
203 | * component might want to register in activity history. | |
204 | * Needs to be implemented in component's information | |
205 | * class. | |
206 | * | |
72b3a70c CW |
207 | * @return array|null |
208 | * collection of activity types | |
186c9c17 | 209 | */ |
1330f57a | 210 | |
186c9c17 EM |
211 | /** |
212 | * @return array|null | |
213 | */ | |
6a488035 TO |
214 | public function getActivityTypes() { |
215 | return NULL; | |
216 | } | |
217 | ||
186c9c17 | 218 | /** |
fe482240 | 219 | * add shortcut to Create New. |
186c9c17 EM |
220 | * @param $shortCuts |
221 | * @param $newCredit | |
222 | */ | |
6a488035 TO |
223 | public function creatNewShortcut(&$shortCuts, $newCredit) { |
224 | if (CRM_Core_Permission::check('access CiviContribute') && | |
225 | CRM_Core_Permission::check('edit contributions') | |
226 | ) { | |
be2fb01f | 227 | $shortCut[] = [ |
6b5ca1ea | 228 | 'path' => 'civicrm/contribute/add', |
229 | 'query' => "reset=1&action=add&context=standalone", | |
230 | 'ref' => 'new-contribution', | |
231 | 'title' => ts('Contribution'), | |
be2fb01f | 232 | ]; |
6a488035 TO |
233 | if ($newCredit) { |
234 | $title = ts('Contribution') . '<br /> (' . ts('credit card') . ')'; | |
be2fb01f | 235 | $shortCut[0]['shortCuts'][] = [ |
6b5ca1ea | 236 | 'path' => 'civicrm/contribute/add', |
237 | 'query' => "reset=1&action=add&context=standalone&mode=live", | |
238 | 'ref' => 'new-contribution-cc', | |
239 | 'title' => $title, | |
be2fb01f | 240 | ]; |
6a488035 | 241 | } |
6b5ca1ea | 242 | $shortCuts = array_merge($shortCuts, $shortCut); |
6a488035 TO |
243 | } |
244 | } | |
96025800 | 245 | |
6a488035 | 246 | } |