Merge pull request #4865 from eileenmcnaughton/my-first-factory
[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 * @static
43 */
44 public static function pmf() {
45 return array(
46 'Both' => ts('Both'),
47 'HTML' => ts('HTML'),
48 'Text' => ts('Text'),
49 );
50 }
51
52 /**
53 * Privacy options
54 * @static
55 */
56 public static function privacy() {
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 );
65 }
66
67 /**
68 * Various pre defined contact super types
69 * @static
70 */
71 public static function contactType() {
72 static $contactType = NULL;
73 if (!$contactType) {
74 $contactType = CRM_Contact_BAO_ContactType::basicTypePairs();
75 }
76 return $contactType;
77 }
78
79 /**
80 * Various pre defined unit list
81 * @static
82 */
83 public static function unitList($unitType = NULL) {
84 $unitList = array(
85 'day' => ts('day'),
86 'month' => ts('month'),
87 'year' => ts('year'),
88 );
89 if ($unitType == 'duration') {
90 $unitList['lifetime'] = ts('lifetime');
91 }
92 return $unitList;
93 }
94
95 /**
96 * Membership type unit
97 * @static
98 */
99 public static function membershipTypeUnitList() {
100 return self::unitList('duration');
101 }
102
103 /**
104 * Various pre defined period types
105 * @static
106 */
107 public static function periodType() {
108 return array(
109 'rolling' => ts('Rolling'),
110 'fixed' => ts('Fixed'),
111 );
112 }
113
114 /**
115 * Various pre defined email selection methods
116 * @static
117 */
118 public static function emailSelectMethods() {
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
127 /**
128 * Various pre defined member visibility options
129 * @static
130 */
131 public static function memberVisibility() {
132 return array(
133 'Public' => ts('Public'),
134 'Admin' => ts('Admin'),
135 );
136 }
137
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
150 /**
151 * Various pre defined event dates
152 * @static
153 */
154 public static function eventDate() {
155 return array(
156 'start_date' => ts('start date'),
157 'end_date' => ts('end date'),
158 'join_date' => ts('member since'),
159 );
160 }
161
162 /**
163 * Custom form field types
164 * @static
165 */
166 public static function customHtmlType() {
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'),
184 'ContactReference' => ts('Autocomplete-Select'),
185 );
186 }
187
188 /**
189 * Various pre defined extensions for dynamic properties and groups
190 *
191 * @static
192 */
193 public static function customGroupExtends() {
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();
211 $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
212 $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects');
213 $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs);
214 return $customGroupExtends;
215 }
216
217 /**
218 * Styles for displaying the custom data group
219 *
220 * @static
221 */
222 public static function customGroupStyle() {
223 return array(
224 'Tab' => ts('Tab'),
225 'Inline' => ts('Inline'),
226 'Tab with table' => ts('Tab with table'),
227 );
228 }
229
230 /**
231 * For displaying the uf group types
232 *
233 * @static
234 */
235 public static function ufGroupTypes() {
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'),
245 );
246 }
247 return $ufGroupType;
248 }
249
250 /**
251 * The status of a contact within a group
252 *
253 * @static
254 */
255 public static function groupContactStatus() {
256 return array(
257 'Added' => ts('Added'),
258 'Removed' => ts('Removed'),
259 'Pending' => ts('Pending'),
260 );
261 }
262
263 /**
264 * List of Group Types
265 * @static
266 */
267 public static function groupType() {
268 return array(
269 'query' => ts('Dynamic'),
270 'static' => ts('Static'),
271 );
272 }
273
274 /**
275 * Compose the parameters for a date select object
276 *
277 * @param string|NULL $type the type of date
278 * @param string|NULL $format date format ( QF format)
279 *
280 * @param null $minOffset
281 * @param null $maxOffset
282 *
283 * @return array the date array
284 * @static
285 */
286 public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) {
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
315 if (empty($date['format'])) {
316 $date['format'] = 'M d';
317 }
318 }
319
320 $year = date('Y');
321 $date['minYear'] = $year - $minOffset;
322 $date['maxYear'] = $year + $maxOffset;
323 return $date;
324 }
325
326 /**
327 * Values for UF form visibility options
328 *
329 * @static
330 */
331 public static function ufVisibility() {
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 );
337 }
338
339 /**
340 * Values for group form visibility options
341 *
342 * @static
343 */
344 public static function groupVisibility() {
345 return array(
346 'User and User Admin Only' => ts('User and User Admin Only'),
347 'Public Pages' => ts('Public Pages'),
348 );
349 }
350
351 /**
352 * Different type of Mailing Components
353 *
354 * @static
355 * return array
356 */
357 public static function mailingComponents() {
358 return array(
359 'Header' => ts('Header'),
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 );
368 }
369
370 /**
371 * Get hours
372 *
373 *
374 * @static
375 */
376 public function getHours() {
377 $hours = array();
378 for ($i = 0; $i <= 6; $i++) {
379 $hours[$i] = $i;
380 }
381 return $hours;
382 }
383
384 /**
385 * Get minutes
386 *
387 *
388 * @static
389 */
390 public function getMinutes() {
391 $minutes = array();
392 for ($i = 0; $i < 60; $i = $i + 15) {
393 $minutes[$i] = $i;
394 }
395 return $minutes;
396 }
397
398 /**
399 * Get the Map Provider
400 *
401 * @return array $map array of map providers
402 * @static
403 */
404 public static function mapProvider() {
405 static $map = NULL;
406 if (!$map) {
407 $map = CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl");
408 }
409 return $map;
410 }
411
412 /**
413 * Get the Geocoding Providers from available plugins
414 *
415 * @return array $geo array of geocoder providers
416 * @static
417 */
418 public static function geoProvider() {
419 static $geo = NULL;
420 if (!$geo) {
421 $geo = CRM_Utils_System::getPluginList('CRM/Utils/Geocode');
422 }
423 return $geo;
424 }
425
426 /**
427 * Get the Address Standardization Providers from available
428 * plugins
429 *
430 * @return array $addr array of address standardization providers
431 * @static
432 */
433 public static function addressProvider() {
434 static $addr = NULL;
435 if (!$addr) {
436 $addr = CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate'));
437 }
438 return $addr;
439 }
440
441 /**
442 * Different type of Mailing Tokens
443 *
444 * @static
445 * return array
446 */
447 public static function mailingTokens() {
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 );
466 }
467
468 /**
469 * Different type of Activity Tokens
470 *
471 * @static
472 * return array
473 */
474 public static function activityTokens() {
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 );
481 }
482
483 /**
484 * Different type of Membership Tokens
485 *
486 * @static
487 * return array
488 */
489 public static function membershipTokens() {
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 );
499 }
500
501 /**
502 * Different type of Event Tokens
503 *
504 * @static
505 * return array
506 */
507 public static function eventTokens() {
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 );
524 }
525
526 /**
527 * Different type of Event Tokens
528 *
529 * @static
530 * return array
531 */
532 public static function contributionTokens() {
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'),
538 '{contribution.non_deductible_amount}' => ts('Non-deductible Amount'),
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 );
558 }
559
560 /**
561 * Different type of Contact Tokens
562 *
563 * @static
564 * return array
565 */
566 public static function contactTokens() {
567 static $tokens = NULL;
568 if (!$tokens) {
569 $additionalFields = array(
570 'checksum' => array('title' => ts('Checksum')),
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 );
583
584 $customFields = CRM_Core_BAO_CustomField::getFields(array('Individual', 'Address'));
585 $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
586
587 foreach ($values as $val) {
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
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 }
598 }
599 else {
600 // Support legacy token names
601 $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val);
602 $tokens["{contact.$tokenName}"] = $exportFields[$val]['title'];
603 }
604 }
605
606 // might as well get all the hook tokens to
607 $hookTokens = array();
608 CRM_Utils_Hook::tokens($hookTokens);
609 foreach ($hookTokens as $tokenValues) {
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
628 /**
629 * Different type of Participant Tokens
630 *
631 * @static
632 * return array
633 */
634 public static function participantTokens() {
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)) {
656 $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
657 }
658 else {
659 $tokens["{participant.$val}"] = $exportFields[$val]['title'];
660 }
661 }
662 }
663 return $tokens;
664 }
665
666 /**
667 * CiviCRM supported date input formats
668 */
669 public static function getDatePluginInputFormats() {
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
701 return $dateInputFormats;
702 }
703
704 /**
705 * Map date plugin and actual format that is used by PHP
706 */
707 public static function datePluginToPHPFormats() {
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 */
731 public static function getTimeFormats() {
732 return array(
733 '1' => ts('12 Hours'),
734 '2' => ts('24 Hours'),
735 );
736 }
737
738 /**
739 * Get numeric options
740 *
741 *
742 * @static
743 */
744 public static function getNumericOptions($start = 0, $end = 10) {
745 $numericOptions = array();
746 for ($i = $start; $i <= $end; $i++) {
747 $numericOptions[$i] = $i;
748 }
749 return $numericOptions;
750 }
751
752 /**
753 * Barcode types
754 * @static
755 */
756 public static function getBarcodeTypes() {
757 return array(
758 'barcode' => ts('Linear (1D)'),
759 'qrcode' => ts('QR code'),
760 );
761 }
762
763 /**
764 * Dedupe rule types
765 */
766 public static function getDedupeRuleTypes() {
767 return array(
768 'Unsupervised' => ts('Unsupervised'),
769 'Supervised' => ts('Supervised'),
770 'General' => ts('General'),
771 );
772 }
773
774 /**
775 * Campaign group types
776 */
777 public static function getCampaignGroupTypes() {
778 return array(
779 'Include' => ts('Include'),
780 'Exclude' => ts('Exclude'),
781 );
782 }
783
784 /**
785 * Subscription history method
786 */
787 public static function getSubscriptionHistoryMethods() {
788 return array(
789 'Admin' => ts('Admin'),
790 'Email' => ts('Email'),
791 'Web' => ts('Web'),
792 'API' => ts('API'),
793 );
794 }
795
796 /**
797 * Premium units
798 */
799 public static function getPremiumUnits() {
800 return array(
801 'day' => ts('Day'),
802 'week' => ts('Week'),
803 'month' => ts('Month'),
804 'year' => ts('Year'),
805 );
806 }
807
808 /**
809 * Extension types
810 */
811 public static function getExtensionTypes() {
812 return array(
813 'payment' => ts('Payment'),
814 'search' => ts('Search'),
815 'report' => ts('Report'),
816 'module' => ts('Module'),
817 'sms' => ts('SMS'),
818 );
819 }
820
821 /**
822 * Job frequency
823 */
824 public static function getJobFrequency() {
825 return array(
826 'Daily' => ts('Daily'),
827 'Hourly' => ts('Hourly'),
828 'Always' => ts('Every time cron job is run'),
829 );
830 }
831
832 /**
833 * Search builder operators
834 */
835 public static function getSearchBuilderOperators() {
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 );
851 }
852
853 /**
854 * Profile group types
855 *
856 * @static
857 */
858 public static function getProfileGroupType() {
859 $profileGroupType = array(
860 'Activity' => ts('Activities'),
861 'Contribution' => ts('Contributions'),
862 'Membership' => ts('Memberships'),
863 'Participant' => ts('Participants'),
864 );
865 $contactTypes = self::contactType();
866 $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
867 $profileGroupType = array_merge($contactTypes, $profileGroupType);
868
869 return $profileGroupType;
870 }
871
872
873 /**
874 * Word replacement match type
875 */
876 public static function getWordReplacementMatchType() {
877 return array(
878 'exactMatch' => ts('Exact Match'),
879 'wildcardMatch' => ts('Wildcard Match'),
880 );
881 }
882
883 /**
884 * Mailing group types
885 */
886 public static function getMailingGroupTypes() {
887 return array(
888 'Include' => ts('Include'),
889 'Exclude' => ts('Exclude'),
890 'Base' => ts('Base'),
891 );
892 }
893
894 /**
895 * Mailing Job Status
896 */
897 public static function getMailingJobStatus() {
898 return array(
899 'Scheduled' => ts('Scheduled'),
900 'Running' => ts('Running'),
901 'Complete' => ts('Complete'),
902 'Paused' => ts('Paused'),
903 'Canceled' => ts('Canceled'),
904 );
905 }
906
907 public static function billingMode() {
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
915 /**
916 * Frequency unit for schedule reminders
917 */
918 public static function getScheduleReminderFrequencyUnits() {
919 //@todo update schema to refer to option group direct & remove this
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 }
928 }