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