QA fixes Round 2
[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
284 * the date array
285 * @static
286 */
287 public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) {
288
289 $date = array(
290 'addEmptyOption' => TRUE,
291 'emptyOptionText' => ts('- select -'),
292 'emptyOptionValue' => '',
293 );
294
295 if ($format) {
296 $date['format'] = $format;
297 }
298 else {
299 if ($type) {
300 $dao = new CRM_Core_DAO_PreferencesDate();
301 $dao->name = $type;
302 if (!$dao->find(TRUE)) {
303 CRM_Core_Error::fatal();
304 }
305 }
306
307 if ($type == 'creditCard') {
308 $minOffset = $dao->start;
309 $maxOffset = $dao->end;
310 $date['format'] = $dao->date_format;
311 $date['addEmptyOption'] = TRUE;
312 $date['emptyOptionText'] = ts('- select -');
313 $date['emptyOptionValue'] = '';
314 }
315
316 if (empty($date['format'])) {
317 $date['format'] = 'M d';
318 }
319 }
320
321 $year = date('Y');
322 $date['minYear'] = $year - $minOffset;
323 $date['maxYear'] = $year + $maxOffset;
324 return $date;
325 }
326
327 /**
328 * Values for UF form visibility options
329 *
330 * @static
331 */
332 public static function ufVisibility() {
333 return array(
334 'User and User Admin Only' => ts('User and User Admin Only'),
335 'Public Pages' => ts('Public Pages'),
336 'Public Pages and Listings' => ts('Public Pages and Listings'),
337 );
338 }
339
340 /**
341 * Values for group form visibility options
342 *
343 * @static
344 */
345 public static function groupVisibility() {
346 return array(
347 'User and User Admin Only' => ts('User and User Admin Only'),
348 'Public Pages' => ts('Public Pages'),
349 );
350 }
351
352 /**
353 * Different type of Mailing Components
354 *
355 * @static
356 * return array
357 */
358 public static function mailingComponents() {
359 return array(
360 'Header' => ts('Header'),
361 'Footer' => ts('Footer'),
362 'Reply' => ts('Reply Auto-responder'),
363 'OptOut' => ts('Opt-out Message'),
364 'Subscribe' => ts('Subscription Confirmation Request'),
365 'Welcome' => ts('Welcome Message'),
366 'Unsubscribe' => ts('Unsubscribe Message'),
367 'Resubscribe' => ts('Resubscribe Message'),
368 );
369 }
370
371 /**
372 * Get hours
373 *
374 *
375 * @static
376 */
377 public function getHours() {
378 $hours = array();
379 for ($i = 0; $i <= 6; $i++) {
380 $hours[$i] = $i;
381 }
382 return $hours;
383 }
384
385 /**
386 * Get minutes
387 *
388 *
389 * @static
390 */
391 public function getMinutes() {
392 $minutes = array();
393 for ($i = 0; $i < 60; $i = $i + 15) {
394 $minutes[$i] = $i;
395 }
396 return $minutes;
397 }
398
399 /**
400 * Get the Map Provider
401 *
402 * @return array
403 * array of map providers
404 * @static
405 */
406 public static function mapProvider() {
407 static $map = NULL;
408 if (!$map) {
409 $map = CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl");
410 }
411 return $map;
412 }
413
414 /**
415 * Get the Geocoding Providers from available plugins
416 *
417 * @return array
418 * array of geocoder providers
419 * @static
420 */
421 public static function geoProvider() {
422 static $geo = NULL;
423 if (!$geo) {
424 $geo = CRM_Utils_System::getPluginList('CRM/Utils/Geocode');
425 }
426 return $geo;
427 }
428
429 /**
430 * Get the Address Standardization Providers from available
431 * plugins
432 *
433 * @return array
434 * array of address standardization providers
435 * @static
436 */
437 public static function addressProvider() {
438 static $addr = NULL;
439 if (!$addr) {
440 $addr = CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate'));
441 }
442 return $addr;
443 }
444
445 /**
446 * Different type of Mailing Tokens
447 *
448 * @static
449 * return array
450 */
451 public static function mailingTokens() {
452 return array(
453 '{action.unsubscribe}' => ts('Unsubscribe via email'),
454 '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'),
455 '{action.resubscribe}' => ts('Resubscribe via email'),
456 '{action.resubscribeUrl}' => ts('Resubscribe via web page'),
457 '{action.optOut}' => ts('Opt out via email'),
458 '{action.optOutUrl}' => ts('Opt out via web page'),
459 '{action.forward}' => ts('Forward this email (link)'),
460 '{action.reply}' => ts('Reply to this email (link)'),
461 '{action.subscribeUrl}' => ts('Subscribe via web page'),
462 '{domain.name}' => ts('Domain name'),
463 '{domain.address}' => ts('Domain (organization) address'),
464 '{domain.phone}' => ts('Domain (organization) phone'),
465 '{domain.email}' => ts('Domain (organization) email'),
466 '{mailing.name}' => ts('Mailing name'),
467 '{mailing.group}' => ts('Mailing group'),
468 '{mailing.viewUrl}' => ts('Mailing permalink'),
469 );
470 }
471
472 /**
473 * Different type of Activity Tokens
474 *
475 * @static
476 * return array
477 */
478 public static function activityTokens() {
479 return array(
480 '{activity.activity_id}' => ts('Activity ID'),
481 '{activity.subject}' => ts('Activity Subject'),
482 '{activity.details}' => ts('Activity Details'),
483 '{activity.activity_date_time}' => ts('Activity Date Time'),
484 );
485 }
486
487 /**
488 * Different type of Membership Tokens
489 *
490 * @static
491 * return array
492 */
493 public static function membershipTokens() {
494 return array(
495 '{membership.id}' => ts('Membership ID'),
496 '{membership.status}' => ts('Membership Status'),
497 '{membership.type}' => ts('Membership Type'),
498 '{membership.start_date}' => ts('Membership Start Date'),
499 '{membership.join_date}' => ts('Membership Join Date'),
500 '{membership.end_date}' => ts('Membership End Date'),
501 '{membership.fee}' => ts('Membership Fee'),
502 );
503 }
504
505 /**
506 * Different type of Event Tokens
507 *
508 * @static
509 * return array
510 */
511 public static function eventTokens() {
512 return array(
513 '{event.event_id}' => ts('Event ID'),
514 '{event.title}' => ts('Event Title'),
515 '{event.start_date}' => ts('Event Start Date'),
516 '{event.end_date}' => ts('Event End Date'),
517 '{event.event_type}' => ts('Event Type'),
518 '{event.summary}' => ts('Event Summary'),
519 '{event.contact_email}' => ts('Event Contact Email'),
520 '{event.contact_phone}' => ts('Event Contact Phone'),
521 '{event.description}' => ts('Event Description'),
522 '{event.location}' => ts('Event Location'),
523 '{event.fee_amount}' => ts('Event Fees'),
524 '{event.info_url}' => ts('Event Info URL'),
525 '{event.registration_url}' => ts('Event Registration URL'),
526 '{event.balance}' => ts('Event Balance'),
527 );
528 }
529
530 /**
531 * Different type of Event Tokens
532 *
533 * @static
534 * return array
535 */
536 public static function contributionTokens() {
537 return array(
538 '{contribution.contribution_id}' => ts('Contribution ID'),
539 '{contribution.total_amount}' => ts('Total Amount'),
540 '{contribution.fee_amount}' => ts('Fee Amount'),
541 '{contribution.net_amount}' => ts('Net Amount'),
542 '{contribution.non_deductible_amount}' => ts('Non-deductible Amount'),
543 '{contribution.receive_date}' => ts('Contribution Receive Date'),
544 '{contribution.payment_instrument}' => ts('Payment Instrument'),
545 '{contribution.trxn_id}' => ts('Transaction ID'),
546 '{contribution.invoice_id}' => ts('Invoice ID'),
547 '{contribution.currency}' => ts('Currency'),
548 '{contribution.cancel_date}' => ts('Contribution Cancel Date'),
549 '{contribution.cancel_reason}' => ts('Contribution Cancel Reason'),
550 '{contribution.receipt_date}' => ts('Receipt Date'),
551 '{contribution.thankyou_date}' => ts('Thank You Date'),
552 '{contribution.contribution_source}' => ts('Contribution Source'),
553 '{contribution.amount_level}' => ts('Amount Level'),
554 //'{contribution.contribution_recur_id}' => ts('Contribution Recurring ID'),
555 //'{contribution.honor_contact_id}' => ts('Honor Contact ID'),
556 '{contribution.contribution_status_id}' => ts('Contribution Status'),
557 //'{contribution.honor_type_id}' => ts('Honor Type ID'),
558 //'{contribution.address_id}' => ts('Address ID'),
559 '{contribution.check_number}' => ts('Check Number'),
560 '{contribution.campaign}' => ts('Contribution Campaign'),
561 );
562 }
563
564 /**
565 * Different type of Contact Tokens
566 *
567 * @static
568 * return array
569 */
570 public static function contactTokens() {
571 static $tokens = NULL;
572 if (!$tokens) {
573 $additionalFields = array(
574 'checksum' => array('title' => ts('Checksum')),
575 'contact_id' => array('title' => ts('Internal Contact ID')),
576 );
577 $exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields);
578
579 $values = array_merge(array_keys($exportFields));
580 unset($values[0]);
581
582 //FIXME:skipping some tokens for time being.
583 $skipTokens = array(
584 'is_bulkmail',
585 'group',
586 'tag',
587 'contact_sub_type',
588 'note',
589 'is_deceased',
590 'deceased_date',
591 'legal_identifier',
592 'contact_sub_type',
593 'user_unique_id',
594 );
595
596 $customFields = CRM_Core_BAO_CustomField::getFields(array('Individual', 'Address'));
597 $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
598
599 foreach ($values as $val) {
600 if (in_array($val, $skipTokens)) {
601 continue;
602 }
603 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
604 $customFieldId = CRM_Core_BAO_CustomField::getKeyID($val);
605 if ($customFieldId) {
606 // CRM-15191 - if key is not in $customFields then the field is disabled and should be ignored
607 if (!empty($customFields[$customFieldId])) {
608 $tokens["{contact.$val}"] = $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'];
609 }
610 }
611 else {
612 // Support legacy token names
613 $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val);
614 $tokens["{contact.$tokenName}"] = $exportFields[$val]['title'];
615 }
616 }
617
618 // might as well get all the hook tokens to
619 $hookTokens = array();
620 CRM_Utils_Hook::tokens($hookTokens);
621 foreach ($hookTokens as $tokenValues) {
622 foreach ($tokenValues as $key => $value) {
623 if (is_numeric($key)) {
624 $key = $value;
625 }
626 if (!preg_match('/^\{[^\}]+\}$/', $key)) {
627 $key = '{' . $key . '}';
628 }
629 if (preg_match('/^\{([^\}]+)\}$/', $value, $matches)) {
630 $value = $matches[1];
631 }
632 $tokens[$key] = $value;
633 }
634 }
635 }
636
637 return $tokens;
638 }
639
640 /**
641 * Different type of Participant Tokens
642 *
643 * @static
644 * return array
645 */
646 public static function participantTokens() {
647 static $tokens = NULL;
648 if (!$tokens) {
649 $exportFields = CRM_Event_BAO_Participant::exportableFields();
650
651 $values = array_merge(array_keys($exportFields));
652 unset($values[0]);
653
654 // skipping some tokens for time being.
655 $skipTokens = array(
656 'event_id',
657 'participant_is_pay_later',
658 'participant_is_test',
659 'participant_contact_id',
660 'participant_fee_currency',
661 'participant_campaign_id',
662 'participant_status',
663 'participant_discount_name',
664 );
665
666 $customFields = CRM_Core_BAO_CustomField::getFields('Participant');
667
668 foreach ($values as $key => $val) {
669 if (in_array($val, $skipTokens)) {
670 continue;
671 }
672 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
673 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
674 $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
675 }
676 else {
677 $tokens["{participant.$val}"] = $exportFields[$val]['title'];
678 }
679 }
680 }
681 return $tokens;
682 }
683
684 /**
685 * CiviCRM supported date input formats
686 */
687 public static function getDatePluginInputFormats() {
688 $dateInputFormats = array(
689 "mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'),
690 "dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'),
691 "yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'),
692 "dd-mm-yy" => ts('dd-mm-yyyy (31-12-2009)'),
693 'dd.mm.yy' => ts('dd.mm.yyyy (31.12.2009)'),
694 "M d, yy" => ts('M d, yyyy (Dec 31, 2009)'),
695 'd M yy' => ts('d M yyyy (31 Dec 2009)'),
696 "MM d, yy" => ts('MM d, yyyy (December 31, 2009)'),
697 'd MM yy' => ts('d MM yyyy (31 December 2009)'),
698 "DD, d MM yy" => ts('DD, d MM yyyy (Thursday, 31 December 2009)'),
699 "mm/dd" => ts('mm/dd (12/31)'),
700 "dd-mm" => ts('dd-mm (31-12)'),
701 "yy-mm" => ts('yyyy-mm (2009-12)'),
702 'M yy' => ts('M yyyy (Dec 2009)'),
703 "yy" => ts('yyyy (2009)'),
704 );
705
706 /*
707 Year greater than 2000 get wrong result for following format
708 echo date( 'Y-m-d', strtotime( '7 Nov, 2001') );
709 echo date( 'Y-m-d', strtotime( '7 November, 2001') );
710 Return current year
711 expected :: 2001-11-07
712 output :: 2009-11-07
713 However
714 echo date( 'Y-m-d', strtotime( 'Nov 7, 2001') );
715 echo date( 'Y-m-d', strtotime( 'November 7, 2001') );
716 gives proper result
717 */
718
719 return $dateInputFormats;
720 }
721
722 /**
723 * Map date plugin and actual format that is used by PHP
724 */
725 public static function datePluginToPHPFormats() {
726 $dateInputFormats = array(
727 "mm/dd/yy" => 'm/d/Y',
728 "dd/mm/yy" => 'd/m/Y',
729 "yy-mm-dd" => 'Y-m-d',
730 "dd-mm-yy" => 'd-m-Y',
731 "dd.mm.yy" => 'd.m.Y',
732 "M d, yy" => 'M j, Y',
733 "d M yy" => 'j M Y',
734 "MM d, yy" => 'F j, Y',
735 "d MM yy" => 'j F Y',
736 "DD, d MM yy" => 'l, j F Y',
737 "mm/dd" => 'm/d',
738 "dd-mm" => 'd-m',
739 "yy-mm" => 'Y-m',
740 "M yy" => 'M Y',
741 "yy" => 'Y',
742 );
743 return $dateInputFormats;
744 }
745
746 /**
747 * Time formats
748 */
749 public static function getTimeFormats() {
750 return array(
751 '1' => ts('12 Hours'),
752 '2' => ts('24 Hours'),
753 );
754 }
755
756 /**
757 * Get numeric options
758 *
759 *
760 * @static
761 */
762 public static function getNumericOptions($start = 0, $end = 10) {
763 $numericOptions = array();
764 for ($i = $start; $i <= $end; $i++) {
765 $numericOptions[$i] = $i;
766 }
767 return $numericOptions;
768 }
769
770 /**
771 * Barcode types
772 * @static
773 */
774 public static function getBarcodeTypes() {
775 return array(
776 'barcode' => ts('Linear (1D)'),
777 'qrcode' => ts('QR code'),
778 );
779 }
780
781 /**
782 * Dedupe rule types
783 */
784 public static function getDedupeRuleTypes() {
785 return array(
786 'Unsupervised' => ts('Unsupervised'),
787 'Supervised' => ts('Supervised'),
788 'General' => ts('General'),
789 );
790 }
791
792 /**
793 * Campaign group types
794 */
795 public static function getCampaignGroupTypes() {
796 return array(
797 'Include' => ts('Include'),
798 'Exclude' => ts('Exclude'),
799 );
800 }
801
802 /**
803 * Subscription history method
804 */
805 public static function getSubscriptionHistoryMethods() {
806 return array(
807 'Admin' => ts('Admin'),
808 'Email' => ts('Email'),
809 'Web' => ts('Web'),
810 'API' => ts('API'),
811 );
812 }
813
814 /**
815 * Premium units
816 */
817 public static function getPremiumUnits() {
818 return array(
819 'day' => ts('Day'),
820 'week' => ts('Week'),
821 'month' => ts('Month'),
822 'year' => ts('Year'),
823 );
824 }
825
826 /**
827 * Extension types
828 */
829 public static function getExtensionTypes() {
830 return array(
831 'payment' => ts('Payment'),
832 'search' => ts('Search'),
833 'report' => ts('Report'),
834 'module' => ts('Module'),
835 'sms' => ts('SMS'),
836 );
837 }
838
839 /**
840 * Job frequency
841 */
842 public static function getJobFrequency() {
843 return array(
844 'Daily' => ts('Daily'),
845 'Hourly' => ts('Hourly'),
846 'Always' => ts('Every time cron job is run'),
847 );
848 }
849
850 /**
851 * Search builder operators
852 */
853 public static function getSearchBuilderOperators() {
854 return array(
855 '=' => '=',
856 '!=' => '≠',
857 '>' => '>',
858 '<' => '<',
859 '>=' => '≥',
860 '<=' => '≤',
861 'IN' => ts('In'),
862 'NOT IN' => ts('Not In'),
863 'LIKE' => ts('Like'),
864 'NOT LIKE' => ts('Not Like'),
865 'RLIKE' => ts('Regex'),
866 'IS EMPTY' => ts('Is Empty'),
867 'IS NOT EMPTY' => ts('Not Empty'),
868 'IS NULL' => ts('Is Null'),
869 'IS NOT NULL' => ts('Not Null'),
870 );
871 }
872
873 /**
874 * Profile group types
875 *
876 * @static
877 */
878 public static function getProfileGroupType() {
879 $profileGroupType = array(
880 'Activity' => ts('Activities'),
881 'Contribution' => ts('Contributions'),
882 'Membership' => ts('Memberships'),
883 'Participant' => ts('Participants'),
884 );
885 $contactTypes = self::contactType();
886 $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
887 $profileGroupType = array_merge($contactTypes, $profileGroupType);
888
889 return $profileGroupType;
890 }
891
892
893 /**
894 * Word replacement match type
895 */
896 public static function getWordReplacementMatchType() {
897 return array(
898 'exactMatch' => ts('Exact Match'),
899 'wildcardMatch' => ts('Wildcard Match'),
900 );
901 }
902
903 /**
904 * Mailing group types
905 */
906 public static function getMailingGroupTypes() {
907 return array(
908 'Include' => ts('Include'),
909 'Exclude' => ts('Exclude'),
910 'Base' => ts('Base'),
911 );
912 }
913
914 /**
915 * Mailing Job Status
916 */
917 public static function getMailingJobStatus() {
918 return array(
919 'Scheduled' => ts('Scheduled'),
920 'Running' => ts('Running'),
921 'Complete' => ts('Complete'),
922 'Paused' => ts('Paused'),
923 'Canceled' => ts('Canceled'),
924 );
925 }
926
927 public static function billingMode() {
928 return array(
929 CRM_Core_Payment::BILLING_MODE_FORM => 'form',
930 CRM_Core_Payment::BILLING_MODE_BUTTON => 'button',
931 CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify',
932 );
933 }
934
935 /**
936 * Frequency unit for schedule reminders
937 */
938 public static function getScheduleReminderFrequencyUnits() {
939 //@todo update schema to refer to option group direct & remove this
940 static $scheduleReminderFrequencyUnits = NULL;
941 if (!$scheduleReminderFrequencyUnits) {
942 $scheduleReminderFrequencyUnits = array(
943 'hour' => ts('hour')
944 ) + CRM_Core_OptionGroup::values('recur_frequency_units');
945 }
946
947 return $scheduleReminderFrequencyUnits;
948 }
949 }