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