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