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