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