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