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