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