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