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 | * One place to store frequently used values in Select Elements. Note that | |
30 | * some of the below elements will be dynamic, so we'll probably have a | |
31 | * smart caching scheme on a per domain basis | |
32 | * | |
33 | * @package CRM | |
e7112fa7 | 34 | * @copyright CiviCRM LLC (c) 2004-2015 |
6a488035 TO |
35 | * $Id$ |
36 | * | |
37 | */ | |
38 | class CRM_Core_SelectValues { | |
39 | ||
14f42e31 CW |
40 | /** |
41 | * Yes/No options | |
42 | * | |
43 | * @return array | |
44 | */ | |
45 | public static function boolean() { | |
46 | return array( | |
47 | 1 => ts('Yes'), | |
48 | 0 => ts('No'), | |
49 | ); | |
50 | } | |
51 | ||
6a488035 | 52 | /** |
f9e31d7f | 53 | * Preferred mail format. |
79d7553f | 54 | * |
76e7a76c | 55 | * @return array |
6a488035 | 56 | */ |
00be9182 | 57 | public static function pmf() { |
6795600d CW |
58 | return array( |
59 | 'Both' => ts('Both'), | |
60 | 'HTML' => ts('HTML'), | |
61 | 'Text' => ts('Text'), | |
62 | ); | |
6a488035 TO |
63 | } |
64 | ||
65 | /** | |
f9e31d7f | 66 | * Privacy options. |
76e7a76c CW |
67 | * |
68 | * @return array | |
6a488035 | 69 | */ |
00be9182 | 70 | public static function privacy() { |
6795600d CW |
71 | return array( |
72 | 'do_not_phone' => ts('Do not phone'), | |
73 | 'do_not_email' => ts('Do not email'), | |
74 | 'do_not_mail' => ts('Do not mail'), | |
75 | 'do_not_sms' => ts('Do not sms'), | |
76 | 'do_not_trade' => ts('Do not trade'), | |
77 | 'is_opt_out' => ts('No bulk emails (User Opt Out)'), | |
78 | ); | |
6a488035 TO |
79 | } |
80 | ||
81 | /** | |
f9e31d7f | 82 | * Various pre defined contact super types. |
76e7a76c CW |
83 | * |
84 | * @return array | |
6a488035 | 85 | */ |
00be9182 | 86 | public static function contactType() { |
6a488035 TO |
87 | static $contactType = NULL; |
88 | if (!$contactType) { | |
694e78fd | 89 | $contactType = CRM_Contact_BAO_ContactType::basicTypePairs(); |
6a488035 TO |
90 | } |
91 | return $contactType; | |
92 | } | |
93 | ||
94 | /** | |
f9e31d7f | 95 | * Various pre defined unit list. |
79d7553f | 96 | * |
76e7a76c CW |
97 | * @param string $unitType |
98 | * @return array | |
6a488035 | 99 | */ |
00be9182 | 100 | public static function unitList($unitType = NULL) { |
c3831ebd EM |
101 | $unitList = array( |
102 | 'day' => ts('day'), | |
103 | 'month' => ts('month'), | |
104 | 'year' => ts('year'), | |
105 | ); | |
106 | if ($unitType == 'duration') { | |
6795600d | 107 | $unitList['lifetime'] = ts('lifetime'); |
6a488035 TO |
108 | } |
109 | return $unitList; | |
110 | } | |
111 | ||
93bfa565 | 112 | /** |
f9e31d7f | 113 | * Membership type unit. |
76e7a76c CW |
114 | * |
115 | * @return array | |
93bfa565 | 116 | */ |
2aa397bc | 117 | public static function membershipTypeUnitList() { |
6795600d | 118 | return self::unitList('duration'); |
93bfa565 | 119 | } |
120 | ||
6a488035 | 121 | /** |
f9e31d7f | 122 | * Various pre defined period types. |
76e7a76c CW |
123 | * |
124 | * @return array | |
6a488035 | 125 | */ |
00be9182 | 126 | public static function periodType() { |
c3831ebd EM |
127 | return array( |
128 | 'rolling' => ts('Rolling'), | |
129 | 'fixed' => ts('Fixed'), | |
130 | ); | |
6a488035 TO |
131 | } |
132 | ||
bac4cd35 | 133 | /** |
f9e31d7f | 134 | * Various pre defined email selection methods. |
76e7a76c CW |
135 | * |
136 | * @return array | |
bac4cd35 | 137 | */ |
00be9182 | 138 | public static function emailSelectMethods() { |
bac4cd35 | 139 | return array( |
140 | 'automatic' => ts("Automatic"), | |
141 | 'location-only' => ts("Only send to email addresses assigned to the specified location"), | |
142 | 'location-prefer' => ts("Prefer email addresses assigned to the specified location"), | |
21dfd5f5 | 143 | 'location-exclude' => ts("Exclude email addresses assigned to the specified location"), |
bac4cd35 | 144 | ); |
145 | } | |
146 | ||
6a488035 | 147 | /** |
f9e31d7f | 148 | * Various pre defined member visibility options. |
76e7a76c CW |
149 | * |
150 | * @return array | |
6a488035 | 151 | */ |
00be9182 | 152 | public static function memberVisibility() { |
ab5e0c41 CW |
153 | return array( |
154 | 'Public' => ts('Public'), | |
155 | 'Admin' => ts('Admin'), | |
156 | ); | |
6a488035 TO |
157 | } |
158 | ||
dbd82592 CW |
159 | /** |
160 | * Member auto-renew options | |
76e7a76c CW |
161 | * |
162 | * @return array | |
dbd82592 CW |
163 | */ |
164 | public static function memberAutoRenew() { | |
165 | return array( | |
166 | ts('No auto-renew option'), | |
167 | ts('Give option, but not required'), | |
21dfd5f5 | 168 | ts('Auto-renew required'), |
dbd82592 CW |
169 | ); |
170 | } | |
171 | ||
6a488035 | 172 | /** |
f9e31d7f | 173 | * Various pre defined event dates. |
76e7a76c CW |
174 | * |
175 | * @return array | |
6a488035 | 176 | */ |
00be9182 | 177 | public static function eventDate() { |
c3831ebd EM |
178 | return array( |
179 | 'start_date' => ts('start date'), | |
180 | 'end_date' => ts('end date'), | |
181 | 'join_date' => ts('member since'), | |
182 | ); | |
6a488035 TO |
183 | } |
184 | ||
6a488035 | 185 | /** |
f9e31d7f | 186 | * Custom form field types. |
76e7a76c CW |
187 | * |
188 | * @return array | |
6a488035 | 189 | */ |
00be9182 | 190 | public static function customHtmlType() { |
c3831ebd EM |
191 | return array( |
192 | 'Text' => ts('Single-line input field (text or numeric)'), | |
193 | 'TextArea' => ts('Multi-line text box (textarea)'), | |
194 | 'Select' => ts('Drop-down (select list)'), | |
195 | 'Radio' => ts('Radio buttons'), | |
196 | 'CheckBox' => ts('Checkbox(es)'), | |
197 | 'Select Date' => ts('Select Date'), | |
198 | 'File' => ts('File'), | |
199 | 'Select State/Province' => ts('Select State/Province'), | |
200 | 'Multi-Select State/Province' => ts('Multi-Select State/Province'), | |
201 | 'Select Country' => ts('Select Country'), | |
202 | 'Multi-Select Country' => ts('Multi-Select Country'), | |
203 | 'RichTextEditor' => ts('Rich Text Editor'), | |
204 | 'Autocomplete-Select' => ts('Autocomplete-Select'), | |
205 | 'Multi-Select' => ts('Multi-Select'), | |
206 | 'AdvMulti-Select' => ts('AdvMulti-Select'), | |
207 | 'Link' => ts('Link'), | |
79dc94e4 | 208 | 'ContactReference' => ts('Autocomplete-Select'), |
c3831ebd | 209 | ); |
6a488035 TO |
210 | } |
211 | ||
212 | /** | |
f9e31d7f | 213 | * Various pre defined extensions for dynamic properties and groups. |
6a488035 | 214 | * |
76e7a76c CW |
215 | * @return array |
216 | * | |
6a488035 | 217 | */ |
00be9182 | 218 | public static function customGroupExtends() { |
c3831ebd EM |
219 | $customGroupExtends = array( |
220 | 'Activity' => ts('Activities'), | |
221 | 'Relationship' => ts('Relationships'), | |
222 | 'Contribution' => ts('Contributions'), | |
223 | 'Group' => ts('Groups'), | |
224 | 'Membership' => ts('Memberships'), | |
225 | 'Event' => ts('Events'), | |
226 | 'Participant' => ts('Participants'), | |
227 | 'ParticipantRole' => ts('Participants (Role)'), | |
228 | 'ParticipantEventName' => ts('Participants (Event Name)'), | |
229 | 'ParticipantEventType' => ts('Participants (Event Type)'), | |
230 | 'Pledge' => ts('Pledges'), | |
231 | 'Grant' => ts('Grants'), | |
232 | 'Address' => ts('Addresses'), | |
233 | 'Campaign' => ts('Campaigns'), | |
234 | ); | |
235 | $contactTypes = self::contactType(); | |
6795600d CW |
236 | $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); |
237 | $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects'); | |
c3831ebd | 238 | $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs); |
6a488035 TO |
239 | return $customGroupExtends; |
240 | } | |
241 | ||
242 | /** | |
f9e31d7f | 243 | * Styles for displaying the custom data group. |
6a488035 | 244 | * |
76e7a76c | 245 | * @return array |
6a488035 | 246 | */ |
00be9182 | 247 | public static function customGroupStyle() { |
c3831ebd EM |
248 | return array( |
249 | 'Tab' => ts('Tab'), | |
250 | 'Inline' => ts('Inline'), | |
251 | 'Tab with table' => ts('Tab with table'), | |
252 | ); | |
6a488035 TO |
253 | } |
254 | ||
255 | /** | |
f9e31d7f | 256 | * For displaying the uf group types. |
6a488035 | 257 | * |
76e7a76c | 258 | * @return array |
6a488035 | 259 | */ |
00be9182 | 260 | public static function ufGroupTypes() { |
c3831ebd EM |
261 | $ufGroupType = array( |
262 | 'Profile' => ts('Standalone Form or Directory'), | |
263 | 'Search Profile' => ts('Search Views'), | |
264 | ); | |
265 | ||
266 | if (CRM_Core_Config::singleton()->userSystem->supports_form_extensions) { | |
267 | $ufGroupType += array( | |
268 | 'User Registration' => ts('Drupal User Registration'), | |
269 | 'User Account' => ts('View/Edit Drupal User Account'), | |
6a488035 | 270 | ); |
6a488035 TO |
271 | } |
272 | return $ufGroupType; | |
273 | } | |
274 | ||
275 | /** | |
f9e31d7f | 276 | * The status of a contact within a group. |
6a488035 | 277 | * |
76e7a76c | 278 | * @return array |
6a488035 | 279 | */ |
00be9182 | 280 | public static function groupContactStatus() { |
c3831ebd EM |
281 | return array( |
282 | 'Added' => ts('Added'), | |
283 | 'Removed' => ts('Removed'), | |
284 | 'Pending' => ts('Pending'), | |
285 | ); | |
6a488035 TO |
286 | } |
287 | ||
288 | /** | |
f9e31d7f | 289 | * List of Group Types. |
76e7a76c CW |
290 | * |
291 | * @return array | |
6a488035 | 292 | */ |
00be9182 | 293 | public static function groupType() { |
c3831ebd EM |
294 | return array( |
295 | 'query' => ts('Dynamic'), | |
296 | 'static' => ts('Static'), | |
297 | ); | |
6a488035 TO |
298 | } |
299 | ||
300 | /** | |
f9e31d7f | 301 | * Compose the parameters for a date select object. |
6a488035 | 302 | * |
76e7a76c CW |
303 | * @param string|NULL $type |
304 | * the type of date | |
305 | * @param string|NULL $format | |
306 | * date format (QF format) | |
9bf2a591 EM |
307 | * @param null $minOffset |
308 | * @param null $maxOffset | |
6a488035 | 309 | * |
a6c01b45 CW |
310 | * @return array |
311 | * the date array | |
6a488035 | 312 | */ |
00be9182 | 313 | public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) { |
6a488035 TO |
314 | $date = array( |
315 | 'addEmptyOption' => TRUE, | |
316 | 'emptyOptionText' => ts('- select -'), | |
317 | 'emptyOptionValue' => '', | |
318 | ); | |
319 | ||
320 | if ($format) { | |
321 | $date['format'] = $format; | |
322 | } | |
323 | else { | |
324 | if ($type) { | |
325 | $dao = new CRM_Core_DAO_PreferencesDate(); | |
326 | $dao->name = $type; | |
327 | if (!$dao->find(TRUE)) { | |
328 | CRM_Core_Error::fatal(); | |
329 | } | |
330 | } | |
331 | ||
332 | if ($type == 'creditCard') { | |
333 | $minOffset = $dao->start; | |
334 | $maxOffset = $dao->end; | |
335 | $date['format'] = $dao->date_format; | |
336 | $date['addEmptyOption'] = TRUE; | |
337 | $date['emptyOptionText'] = ts('- select -'); | |
338 | $date['emptyOptionValue'] = ''; | |
339 | } | |
340 | ||
a7488080 | 341 | if (empty($date['format'])) { |
6a488035 TO |
342 | $date['format'] = 'M d'; |
343 | } | |
344 | } | |
345 | ||
6795600d | 346 | $year = date('Y'); |
6a488035 TO |
347 | $date['minYear'] = $year - $minOffset; |
348 | $date['maxYear'] = $year + $maxOffset; | |
349 | return $date; | |
350 | } | |
351 | ||
352 | /** | |
f9e31d7f | 353 | * Values for UF form visibility options. |
6a488035 | 354 | * |
76e7a76c | 355 | * @return array |
6a488035 | 356 | */ |
00be9182 | 357 | public static function ufVisibility() { |
c3831ebd EM |
358 | return array( |
359 | 'User and User Admin Only' => ts('User and User Admin Only'), | |
360 | 'Public Pages' => ts('Public Pages'), | |
361 | 'Public Pages and Listings' => ts('Public Pages and Listings'), | |
362 | ); | |
6a488035 TO |
363 | } |
364 | ||
93bfa565 | 365 | /** |
f9e31d7f | 366 | * Values for group form visibility options. |
93bfa565 | 367 | * |
76e7a76c | 368 | * @return array |
93bfa565 | 369 | */ |
00be9182 | 370 | public static function groupVisibility() { |
c3831ebd | 371 | return array( |
6795600d CW |
372 | 'User and User Admin Only' => ts('User and User Admin Only'), |
373 | 'Public Pages' => ts('Public Pages'), | |
374 | ); | |
93bfa565 | 375 | } |
376 | ||
6a488035 | 377 | /** |
f9e31d7f | 378 | * Different type of Mailing Components. |
6a488035 | 379 | * |
76e7a76c | 380 | * @return array |
6a488035 | 381 | */ |
00be9182 | 382 | public static function mailingComponents() { |
2aa397bc | 383 | return array( |
353ffa53 | 384 | 'Header' => ts('Header'), |
c3831ebd EM |
385 | 'Footer' => ts('Footer'), |
386 | 'Reply' => ts('Reply Auto-responder'), | |
387 | 'OptOut' => ts('Opt-out Message'), | |
388 | 'Subscribe' => ts('Subscription Confirmation Request'), | |
389 | 'Welcome' => ts('Welcome Message'), | |
390 | 'Unsubscribe' => ts('Unsubscribe Message'), | |
391 | 'Resubscribe' => ts('Resubscribe Message'), | |
392 | ); | |
6a488035 TO |
393 | } |
394 | ||
395 | /** | |
f9e31d7f | 396 | * Get hours. |
6a488035 | 397 | * |
76e7a76c | 398 | * @return array |
6a488035 | 399 | */ |
00be9182 | 400 | public function getHours() { |
9fab6f51 | 401 | $hours = array(); |
6a488035 TO |
402 | for ($i = 0; $i <= 6; $i++) { |
403 | $hours[$i] = $i; | |
404 | } | |
405 | return $hours; | |
406 | } | |
407 | ||
408 | /** | |
f9e31d7f | 409 | * Get minutes. |
6a488035 | 410 | * |
76e7a76c | 411 | * @return array |
6a488035 | 412 | */ |
00be9182 | 413 | public function getMinutes() { |
9fab6f51 | 414 | $minutes = array(); |
6a488035 TO |
415 | for ($i = 0; $i < 60; $i = $i + 15) { |
416 | $minutes[$i] = $i; | |
417 | } | |
418 | return $minutes; | |
419 | } | |
420 | ||
421 | /** | |
f9e31d7f | 422 | * Get the Map Provider. |
6a488035 | 423 | * |
a6c01b45 CW |
424 | * @return array |
425 | * array of map providers | |
6a488035 | 426 | */ |
00be9182 | 427 | public static function mapProvider() { |
6a488035 TO |
428 | static $map = NULL; |
429 | if (!$map) { | |
6795600d | 430 | $map = CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl"); |
6a488035 TO |
431 | } |
432 | return $map; | |
433 | } | |
434 | ||
435 | /** | |
f9e31d7f | 436 | * Get the Geocoding Providers from available plugins. |
6a488035 | 437 | * |
a6c01b45 CW |
438 | * @return array |
439 | * array of geocoder providers | |
6a488035 | 440 | */ |
00be9182 | 441 | public static function geoProvider() { |
6a488035 TO |
442 | static $geo = NULL; |
443 | if (!$geo) { | |
6795600d | 444 | $geo = CRM_Utils_System::getPluginList('CRM/Utils/Geocode'); |
6a488035 TO |
445 | } |
446 | return $geo; | |
447 | } | |
448 | ||
449 | /** | |
f9e31d7f | 450 | * Get the Address Standardization Providers from available plugins. |
6a488035 | 451 | * |
a6c01b45 CW |
452 | * @return array |
453 | * array of address standardization providers | |
6a488035 | 454 | */ |
00be9182 | 455 | public static function addressProvider() { |
6a488035 TO |
456 | static $addr = NULL; |
457 | if (!$addr) { | |
6795600d | 458 | $addr = CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate')); |
6a488035 TO |
459 | } |
460 | return $addr; | |
461 | } | |
462 | ||
463 | /** | |
f9e31d7f | 464 | * Different type of Mailing Tokens. |
6a488035 | 465 | * |
76e7a76c | 466 | * @return array |
6a488035 | 467 | */ |
00be9182 | 468 | public static function mailingTokens() { |
c3831ebd EM |
469 | return array( |
470 | '{action.unsubscribe}' => ts('Unsubscribe via email'), | |
471 | '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'), | |
472 | '{action.resubscribe}' => ts('Resubscribe via email'), | |
473 | '{action.resubscribeUrl}' => ts('Resubscribe via web page'), | |
474 | '{action.optOut}' => ts('Opt out via email'), | |
475 | '{action.optOutUrl}' => ts('Opt out via web page'), | |
476 | '{action.forward}' => ts('Forward this email (link)'), | |
477 | '{action.reply}' => ts('Reply to this email (link)'), | |
478 | '{action.subscribeUrl}' => ts('Subscribe via web page'), | |
479 | '{domain.name}' => ts('Domain name'), | |
480 | '{domain.address}' => ts('Domain (organization) address'), | |
481 | '{domain.phone}' => ts('Domain (organization) phone'), | |
482 | '{domain.email}' => ts('Domain (organization) email'), | |
483 | '{mailing.name}' => ts('Mailing name'), | |
484 | '{mailing.group}' => ts('Mailing group'), | |
485 | '{mailing.viewUrl}' => ts('Mailing permalink'), | |
486 | ); | |
6a488035 TO |
487 | } |
488 | ||
489 | /** | |
f9e31d7f | 490 | * Different type of Activity Tokens. |
6a488035 | 491 | * |
76e7a76c | 492 | * @return array |
6a488035 | 493 | */ |
00be9182 | 494 | public static function activityTokens() { |
c3831ebd EM |
495 | return array( |
496 | '{activity.activity_id}' => ts('Activity ID'), | |
497 | '{activity.subject}' => ts('Activity Subject'), | |
498 | '{activity.details}' => ts('Activity Details'), | |
499 | '{activity.activity_date_time}' => ts('Activity Date Time'), | |
500 | ); | |
6a488035 TO |
501 | } |
502 | ||
503 | /** | |
f9e31d7f | 504 | * Different type of Membership Tokens. |
6a488035 | 505 | * |
76e7a76c | 506 | * @return array |
6a488035 | 507 | */ |
00be9182 | 508 | public static function membershipTokens() { |
c3831ebd EM |
509 | return array( |
510 | '{membership.id}' => ts('Membership ID'), | |
511 | '{membership.status}' => ts('Membership Status'), | |
512 | '{membership.type}' => ts('Membership Type'), | |
513 | '{membership.start_date}' => ts('Membership Start Date'), | |
514 | '{membership.join_date}' => ts('Membership Join Date'), | |
515 | '{membership.end_date}' => ts('Membership End Date'), | |
516 | '{membership.fee}' => ts('Membership Fee'), | |
517 | ); | |
6a488035 TO |
518 | } |
519 | ||
520 | /** | |
f9e31d7f | 521 | * Different type of Event Tokens. |
6a488035 | 522 | * |
76e7a76c | 523 | * @return array |
6a488035 | 524 | */ |
00be9182 | 525 | public static function eventTokens() { |
c3831ebd EM |
526 | return array( |
527 | '{event.event_id}' => ts('Event ID'), | |
528 | '{event.title}' => ts('Event Title'), | |
529 | '{event.start_date}' => ts('Event Start Date'), | |
530 | '{event.end_date}' => ts('Event End Date'), | |
531 | '{event.event_type}' => ts('Event Type'), | |
532 | '{event.summary}' => ts('Event Summary'), | |
533 | '{event.contact_email}' => ts('Event Contact Email'), | |
534 | '{event.contact_phone}' => ts('Event Contact Phone'), | |
535 | '{event.description}' => ts('Event Description'), | |
536 | '{event.location}' => ts('Event Location'), | |
537 | '{event.fee_amount}' => ts('Event Fees'), | |
538 | '{event.info_url}' => ts('Event Info URL'), | |
539 | '{event.registration_url}' => ts('Event Registration URL'), | |
21dfd5f5 | 540 | '{event.balance}' => ts('Event Balance'), |
c3831ebd | 541 | ); |
6a488035 TO |
542 | } |
543 | ||
544 | /** | |
f9e31d7f | 545 | * Different type of Event Tokens. |
6a488035 | 546 | * |
76e7a76c | 547 | * @return array |
6a488035 | 548 | */ |
00be9182 | 549 | public static function contributionTokens() { |
c3831ebd EM |
550 | return array( |
551 | '{contribution.contribution_id}' => ts('Contribution ID'), | |
552 | '{contribution.total_amount}' => ts('Total Amount'), | |
553 | '{contribution.fee_amount}' => ts('Fee Amount'), | |
554 | '{contribution.net_amount}' => ts('Net Amount'), | |
c94fc35e | 555 | '{contribution.non_deductible_amount}' => ts('Non-deductible Amount'), |
7bc6b5bb | 556 | '{contribution.receive_date}' => ts('Contribution Date Received'), |
536f0e02 | 557 | '{contribution.payment_instrument}' => ts('Payment Method'), |
c3831ebd EM |
558 | '{contribution.trxn_id}' => ts('Transaction ID'), |
559 | '{contribution.invoice_id}' => ts('Invoice ID'), | |
560 | '{contribution.currency}' => ts('Currency'), | |
561 | '{contribution.cancel_date}' => ts('Contribution Cancel Date'), | |
562 | '{contribution.cancel_reason}' => ts('Contribution Cancel Reason'), | |
563 | '{contribution.receipt_date}' => ts('Receipt Date'), | |
564 | '{contribution.thankyou_date}' => ts('Thank You Date'), | |
565 | '{contribution.contribution_source}' => ts('Contribution Source'), | |
566 | '{contribution.amount_level}' => ts('Amount Level'), | |
567 | //'{contribution.contribution_recur_id}' => ts('Contribution Recurring ID'), | |
568 | //'{contribution.honor_contact_id}' => ts('Honor Contact ID'), | |
569 | '{contribution.contribution_status_id}' => ts('Contribution Status'), | |
570 | //'{contribution.honor_type_id}' => ts('Honor Type ID'), | |
571 | //'{contribution.address_id}' => ts('Address ID'), | |
572 | '{contribution.check_number}' => ts('Check Number'), | |
573 | '{contribution.campaign}' => ts('Contribution Campaign'), | |
574 | ); | |
6a488035 TO |
575 | } |
576 | ||
577 | /** | |
f9e31d7f | 578 | * Different type of Contact Tokens. |
6a488035 | 579 | * |
76e7a76c | 580 | * @return array |
6a488035 | 581 | */ |
00be9182 | 582 | public static function contactTokens() { |
6a488035 TO |
583 | static $tokens = NULL; |
584 | if (!$tokens) { | |
2aa397bc | 585 | $additionalFields = array( |
353ffa53 | 586 | 'checksum' => array('title' => ts('Checksum')), |
6a488035 TO |
587 | 'contact_id' => array('title' => ts('Internal Contact ID')), |
588 | ); | |
589 | $exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields); | |
590 | ||
591 | $values = array_merge(array_keys($exportFields)); | |
592 | unset($values[0]); | |
593 | ||
594 | //FIXME:skipping some tokens for time being. | |
595 | $skipTokens = array( | |
353ffa53 TO |
596 | 'is_bulkmail', |
597 | 'group', | |
598 | 'tag', | |
599 | 'contact_sub_type', | |
600 | 'note', | |
601 | 'is_deceased', | |
602 | 'deceased_date', | |
603 | 'legal_identifier', | |
604 | 'contact_sub_type', | |
605 | 'user_unique_id', | |
6a488035 | 606 | ); |
ea921622 | 607 | |
72e34731 | 608 | $customFields = CRM_Core_BAO_CustomField::getFields(array('Individual', 'Address')); |
cc615373 | 609 | $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens()); |
6a488035 | 610 | |
cc615373 | 611 | foreach ($values as $val) { |
6a488035 TO |
612 | if (in_array($val, $skipTokens)) { |
613 | continue; | |
614 | } | |
615 | //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734 | |
72e34731 CW |
616 | $customFieldId = CRM_Core_BAO_CustomField::getKeyID($val); |
617 | if ($customFieldId) { | |
618 | // CRM-15191 - if key is not in $customFields then the field is disabled and should be ignored | |
619 | if (!empty($customFields[$customFieldId])) { | |
620 | $tokens["{contact.$val}"] = $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle']; | |
621 | } | |
6a488035 TO |
622 | } |
623 | else { | |
cc615373 CW |
624 | // Support legacy token names |
625 | $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val); | |
626 | $tokens["{contact.$tokenName}"] = $exportFields[$val]['title']; | |
6a488035 TO |
627 | } |
628 | } | |
629 | ||
9950a1c9 | 630 | // Get all the hook tokens too |
6a488035 TO |
631 | $hookTokens = array(); |
632 | CRM_Utils_Hook::tokens($hookTokens); | |
94bf1070 | 633 | foreach ($hookTokens as $tokenValues) { |
6a488035 TO |
634 | foreach ($tokenValues as $key => $value) { |
635 | if (is_numeric($key)) { | |
636 | $key = $value; | |
637 | } | |
638 | if (!preg_match('/^\{[^\}]+\}$/', $key)) { | |
639 | $key = '{' . $key . '}'; | |
640 | } | |
641 | if (preg_match('/^\{([^\}]+)\}$/', $value, $matches)) { | |
642 | $value = $matches[1]; | |
643 | } | |
644 | $tokens[$key] = $value; | |
645 | } | |
646 | } | |
647 | } | |
648 | ||
649 | return $tokens; | |
650 | } | |
651 | ||
ea921622 | 652 | /** |
f9e31d7f | 653 | * Different type of Participant Tokens. |
ea921622 | 654 | * |
76e7a76c | 655 | * @return array |
ea921622 | 656 | */ |
00be9182 | 657 | public static function participantTokens() { |
ea921622 KJ |
658 | static $tokens = NULL; |
659 | if (!$tokens) { | |
660 | $exportFields = CRM_Event_BAO_Participant::exportableFields(); | |
661 | ||
662 | $values = array_merge(array_keys($exportFields)); | |
663 | unset($values[0]); | |
664 | ||
665 | // skipping some tokens for time being. | |
666 | $skipTokens = array( | |
353ffa53 TO |
667 | 'event_id', |
668 | 'participant_is_pay_later', | |
669 | 'participant_is_test', | |
670 | 'participant_contact_id', | |
671 | 'participant_fee_currency', | |
672 | 'participant_campaign_id', | |
673 | 'participant_status', | |
674 | 'participant_discount_name', | |
ea921622 KJ |
675 | ); |
676 | ||
677 | $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); | |
678 | ||
679 | foreach ($values as $key => $val) { | |
680 | if (in_array($val, $skipTokens)) { | |
681 | continue; | |
682 | } | |
683 | //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734 | |
684 | if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) { | |
0d8afee2 | 685 | $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : ''; |
ea921622 KJ |
686 | } |
687 | else { | |
688 | $tokens["{participant.$val}"] = $exportFields[$val]['title']; | |
689 | } | |
690 | } | |
691 | } | |
692 | return $tokens; | |
693 | } | |
694 | ||
6a488035 | 695 | /** |
f9e31d7f | 696 | * CiviCRM supported date input formats. |
76e7a76c CW |
697 | * |
698 | * @return array | |
6a488035 | 699 | */ |
00be9182 | 700 | public static function getDatePluginInputFormats() { |
6a488035 TO |
701 | $dateInputFormats = array( |
702 | "mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'), | |
703 | "dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'), | |
704 | "yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'), | |
705 | "dd-mm-yy" => ts('dd-mm-yyyy (31-12-2009)'), | |
706 | 'dd.mm.yy' => ts('dd.mm.yyyy (31.12.2009)'), | |
707 | "M d, yy" => ts('M d, yyyy (Dec 31, 2009)'), | |
708 | 'd M yy' => ts('d M yyyy (31 Dec 2009)'), | |
709 | "MM d, yy" => ts('MM d, yyyy (December 31, 2009)'), | |
710 | 'd MM yy' => ts('d MM yyyy (31 December 2009)'), | |
711 | "DD, d MM yy" => ts('DD, d MM yyyy (Thursday, 31 December 2009)'), | |
712 | "mm/dd" => ts('mm/dd (12/31)'), | |
713 | "dd-mm" => ts('dd-mm (31-12)'), | |
714 | "yy-mm" => ts('yyyy-mm (2009-12)'), | |
715 | 'M yy' => ts('M yyyy (Dec 2009)'), | |
716 | "yy" => ts('yyyy (2009)'), | |
717 | ); | |
718 | ||
719 | /* | |
e70a7fc0 TO |
720 | Year greater than 2000 get wrong result for following format |
721 | echo date( 'Y-m-d', strtotime( '7 Nov, 2001') ); | |
722 | echo date( 'Y-m-d', strtotime( '7 November, 2001') ); | |
723 | Return current year | |
724 | expected :: 2001-11-07 | |
725 | output :: 2009-11-07 | |
726 | However | |
727 | echo date( 'Y-m-d', strtotime( 'Nov 7, 2001') ); | |
728 | echo date( 'Y-m-d', strtotime( 'November 7, 2001') ); | |
729 | gives proper result | |
76e7a76c | 730 | */ |
6a488035 | 731 | |
6a488035 TO |
732 | return $dateInputFormats; |
733 | } | |
734 | ||
735 | /** | |
f9e31d7f | 736 | * Map date plugin and actual format that is used by PHP. |
76e7a76c CW |
737 | * |
738 | * @return array | |
6a488035 | 739 | */ |
00be9182 | 740 | public static function datePluginToPHPFormats() { |
6a488035 TO |
741 | $dateInputFormats = array( |
742 | "mm/dd/yy" => 'm/d/Y', | |
743 | "dd/mm/yy" => 'd/m/Y', | |
744 | "yy-mm-dd" => 'Y-m-d', | |
745 | "dd-mm-yy" => 'd-m-Y', | |
746 | "dd.mm.yy" => 'd.m.Y', | |
747 | "M d, yy" => 'M j, Y', | |
748 | "d M yy" => 'j M Y', | |
749 | "MM d, yy" => 'F j, Y', | |
750 | "d MM yy" => 'j F Y', | |
751 | "DD, d MM yy" => 'l, j F Y', | |
752 | "mm/dd" => 'm/d', | |
753 | "dd-mm" => 'd-m', | |
754 | "yy-mm" => 'Y-m', | |
755 | "M yy" => 'M Y', | |
756 | "yy" => 'Y', | |
757 | ); | |
758 | return $dateInputFormats; | |
759 | } | |
760 | ||
761 | /** | |
f9e31d7f | 762 | * Time formats. |
76e7a76c CW |
763 | * |
764 | * @return array | |
6a488035 | 765 | */ |
00be9182 | 766 | public static function getTimeFormats() { |
6795600d CW |
767 | return array( |
768 | '1' => ts('12 Hours'), | |
6a488035 TO |
769 | '2' => ts('24 Hours'), |
770 | ); | |
6a488035 TO |
771 | } |
772 | ||
773 | /** | |
f9e31d7f | 774 | * Get numeric options. |
79d7553f | 775 | * |
76e7a76c CW |
776 | * @param int $start |
777 | * @param int $end | |
6a488035 | 778 | * |
76e7a76c | 779 | * @return array |
6a488035 TO |
780 | */ |
781 | public static function getNumericOptions($start = 0, $end = 10) { | |
9fab6f51 | 782 | $numericOptions = array(); |
6a488035 | 783 | for ($i = $start; $i <= $end; $i++) { |
2aa397bc | 784 | $numericOptions[$i] = $i; |
6a488035 TO |
785 | } |
786 | return $numericOptions; | |
787 | } | |
f38395f7 KJ |
788 | |
789 | /** | |
f9e31d7f | 790 | * Barcode types. |
76e7a76c CW |
791 | * |
792 | * @return array | |
f38395f7 | 793 | */ |
00be9182 | 794 | public static function getBarcodeTypes() { |
c3831ebd EM |
795 | return array( |
796 | 'barcode' => ts('Linear (1D)'), | |
797 | 'qrcode' => ts('QR code'), | |
798 | ); | |
f38395f7 | 799 | } |
77d0b1f8 | 800 | |
801 | /** | |
f9e31d7f | 802 | * Dedupe rule types. |
76e7a76c CW |
803 | * |
804 | * @return array | |
77d0b1f8 | 805 | */ |
00be9182 | 806 | public static function getDedupeRuleTypes() { |
c3831ebd EM |
807 | return array( |
808 | 'Unsupervised' => ts('Unsupervised'), | |
809 | 'Supervised' => ts('Supervised'), | |
810 | 'General' => ts('General'), | |
811 | ); | |
77d0b1f8 | 812 | } |
f80ce889 | 813 | |
814 | /** | |
f9e31d7f | 815 | * Campaign group types. |
76e7a76c CW |
816 | * |
817 | * @return array | |
f80ce889 | 818 | */ |
00be9182 | 819 | public static function getCampaignGroupTypes() { |
c3831ebd EM |
820 | return array( |
821 | 'Include' => ts('Include'), | |
822 | 'Exclude' => ts('Exclude'), | |
823 | ); | |
f80ce889 | 824 | } |
825 | ||
826 | /** | |
f9e31d7f | 827 | * Subscription history method. |
76e7a76c CW |
828 | * |
829 | * @return array | |
f80ce889 | 830 | */ |
00be9182 | 831 | public static function getSubscriptionHistoryMethods() { |
c3831ebd EM |
832 | return array( |
833 | 'Admin' => ts('Admin'), | |
834 | 'Email' => ts('Email'), | |
835 | 'Web' => ts('Web'), | |
836 | 'API' => ts('API'), | |
837 | ); | |
f80ce889 | 838 | } |
839 | ||
840 | /** | |
f9e31d7f | 841 | * Premium units. |
76e7a76c CW |
842 | * |
843 | * @return array | |
f80ce889 | 844 | */ |
00be9182 | 845 | public static function getPremiumUnits() { |
c3831ebd EM |
846 | return array( |
847 | 'day' => ts('Day'), | |
848 | 'week' => ts('Week'), | |
849 | 'month' => ts('Month'), | |
850 | 'year' => ts('Year'), | |
851 | ); | |
f80ce889 | 852 | } |
56251ea7 | 853 | |
854 | /** | |
f9e31d7f | 855 | * Extension types. |
76e7a76c CW |
856 | * |
857 | * @return array | |
56251ea7 | 858 | */ |
00be9182 | 859 | public static function getExtensionTypes() { |
2aa397bc | 860 | return array( |
c3831ebd EM |
861 | 'payment' => ts('Payment'), |
862 | 'search' => ts('Search'), | |
863 | 'report' => ts('Report'), | |
864 | 'module' => ts('Module'), | |
865 | 'sms' => ts('SMS'), | |
866 | ); | |
56251ea7 | 867 | } |
868 | ||
869 | /** | |
f9e31d7f | 870 | * Job frequency. |
76e7a76c CW |
871 | * |
872 | * @return array | |
56251ea7 | 873 | */ |
00be9182 | 874 | public static function getJobFrequency() { |
c3831ebd | 875 | return array( |
7fce7b7f B |
876 | '1stOfQtr' => ts('1st day of every quarter'), |
877 | '1stOfMth' => ts('1st day of every month'), | |
878 | 'Mondays' => ts('Monday of every week'), | |
c3831ebd EM |
879 | 'Daily' => ts('Daily'), |
880 | 'Hourly' => ts('Hourly'), | |
881 | 'Always' => ts('Every time cron job is run'), | |
882 | ); | |
56251ea7 | 883 | } |
e204d358 | 884 | |
885 | /** | |
f9e31d7f | 886 | * Search builder operators. |
76e7a76c CW |
887 | * |
888 | * @return array | |
e204d358 | 889 | */ |
00be9182 | 890 | public static function getSearchBuilderOperators() { |
c3831ebd EM |
891 | return array( |
892 | '=' => '=', | |
893 | '!=' => '≠', | |
894 | '>' => '>', | |
895 | '<' => '<', | |
896 | '>=' => '≥', | |
897 | '<=' => '≤', | |
898 | 'IN' => ts('In'), | |
afa0b07c | 899 | 'NOT IN' => ts('Not In'), |
c3831ebd | 900 | 'LIKE' => ts('Like'), |
afa0b07c | 901 | 'NOT LIKE' => ts('Not Like'), |
c3831ebd EM |
902 | 'RLIKE' => ts('Regex'), |
903 | 'IS EMPTY' => ts('Is Empty'), | |
904 | 'IS NOT EMPTY' => ts('Not Empty'), | |
905 | 'IS NULL' => ts('Is Null'), | |
906 | 'IS NOT NULL' => ts('Not Null'), | |
907 | ); | |
e204d358 | 908 | } |
909 | ||
910 | /** | |
f9e31d7f | 911 | * Profile group types. |
e204d358 | 912 | * |
76e7a76c | 913 | * @return array |
e204d358 | 914 | */ |
00be9182 | 915 | public static function getProfileGroupType() { |
c3831ebd EM |
916 | $profileGroupType = array( |
917 | 'Activity' => ts('Activities'), | |
918 | 'Contribution' => ts('Contributions'), | |
919 | 'Membership' => ts('Memberships'), | |
920 | 'Participant' => ts('Participants'), | |
921 | ); | |
922 | $contactTypes = self::contactType(); | |
6795600d | 923 | $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); |
481a74f4 | 924 | $profileGroupType = array_merge($contactTypes, $profileGroupType); |
c3831ebd | 925 | |
e204d358 | 926 | return $profileGroupType; |
927 | } | |
928 | ||
929 | ||
930 | /** | |
f9e31d7f | 931 | * Word replacement match type. |
76e7a76c CW |
932 | * |
933 | * @return array | |
e204d358 | 934 | */ |
00be9182 | 935 | public static function getWordReplacementMatchType() { |
c3831ebd | 936 | return array( |
353ffa53 TO |
937 | 'exactMatch' => ts('Exact Match'), |
938 | 'wildcardMatch' => ts('Wildcard Match'), | |
939 | ); | |
e204d358 | 940 | } |
941 | ||
71a707c3 | 942 | /** |
f9e31d7f | 943 | * Mailing group types. |
76e7a76c CW |
944 | * |
945 | * @return array | |
71a707c3 | 946 | */ |
00be9182 | 947 | public static function getMailingGroupTypes() { |
c3831ebd EM |
948 | return array( |
949 | 'Include' => ts('Include'), | |
950 | 'Exclude' => ts('Exclude'), | |
951 | 'Base' => ts('Base'), | |
952 | ); | |
71a707c3 | 953 | } |
954 | ||
955 | /** | |
f9e31d7f | 956 | * Mailing Job Status. |
76e7a76c CW |
957 | * |
958 | * @return array | |
71a707c3 | 959 | */ |
00be9182 | 960 | public static function getMailingJobStatus() { |
c3831ebd EM |
961 | return array( |
962 | 'Scheduled' => ts('Scheduled'), | |
963 | 'Running' => ts('Running'), | |
964 | 'Complete' => ts('Complete'), | |
965 | 'Paused' => ts('Paused'), | |
966 | 'Canceled' => ts('Canceled'), | |
967 | ); | |
71a707c3 | 968 | } |
969 | ||
76e7a76c CW |
970 | /** |
971 | * @return array | |
972 | */ | |
00be9182 | 973 | public static function billingMode() { |
280f1b05 CW |
974 | return array( |
975 | CRM_Core_Payment::BILLING_MODE_FORM => 'form', | |
976 | CRM_Core_Payment::BILLING_MODE_BUTTON => 'button', | |
977 | CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', | |
978 | ); | |
979 | } | |
980 | ||
9775f926 | 981 | /** |
f9e31d7f | 982 | * Frequency unit for schedule reminders. |
76e7a76c | 983 | * |
8fe4b69f CW |
984 | * @param int $count |
985 | * For pluralization | |
76e7a76c | 986 | * @return array |
9775f926 | 987 | */ |
8fe4b69f CW |
988 | public static function getRecurringFrequencyUnits($count = 1) { |
989 | // @todo this used to refer to the 'recur_frequency_unit' option_values which | |
990 | // is for recurring payments and probably not good to re-use for recurring entities. | |
991 | // If something other than a hard-coded list is desired, add a new option_group. | |
992 | return array( | |
993 | 'hour' => ts('hour', array('plural' => 'hours', 'count' => $count)), | |
994 | 'day' => ts('day', array('plural' => 'days', 'count' => $count)), | |
995 | 'week' => ts('week', array('plural' => 'weeks', 'count' => $count)), | |
996 | 'month' => ts('month', array('plural' => 'months', 'count' => $count)), | |
997 | 'year' => ts('year', array('plural' => 'years', 'count' => $count)), | |
998 | ); | |
9775f926 | 999 | } |
96025800 | 1000 | |
6a488035 | 1001 | } |