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