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