Merge pull request #3776 from crusonweb/patch-3
[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('Individual');
558 $customFieldsAddress = CRM_Core_BAO_CustomField::getFields('Address');
559 $customFields = $customFields + $customFieldsAddress;
560 $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
561
562 foreach ($values as $val) {
563 if (in_array($val, $skipTokens)) {
564 continue;
565 }
566 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
567 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
568 $tokens["{contact.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
569 }
570 else {
571 // Support legacy token names
572 $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val);
573 $tokens["{contact.$tokenName}"] = $exportFields[$val]['title'];
574 }
575 }
576
577 // might as well get all the hook tokens to
578 $hookTokens = array();
579 CRM_Utils_Hook::tokens($hookTokens);
580 foreach ($hookTokens as $tokenValues) {
581 foreach ($tokenValues as $key => $value) {
582 if (is_numeric($key)) {
583 $key = $value;
584 }
585 if (!preg_match('/^\{[^\}]+\}$/', $key)) {
586 $key = '{' . $key . '}';
587 }
588 if (preg_match('/^\{([^\}]+)\}$/', $value, $matches)) {
589 $value = $matches[1];
590 }
591 $tokens[$key] = $value;
592 }
593 }
594 }
595
596 return $tokens;
597 }
598
599 /**
600 * different type of Participant Tokens
601 *
602 * @static
603 * return array
604 */
605 static function participantTokens() {
606 static $tokens = NULL;
607 if (!$tokens) {
608 $exportFields = CRM_Event_BAO_Participant::exportableFields();
609
610 $values = array_merge(array_keys($exportFields));
611 unset($values[0]);
612
613 // skipping some tokens for time being.
614 $skipTokens = array(
615 'event_id', 'participant_is_pay_later', 'participant_is_test', 'participant_contact_id',
616 'participant_fee_currency', 'participant_campaign_id', 'participant_status', 'participant_discount_name',
617 );
618
619 $customFields = CRM_Core_BAO_CustomField::getFields('Participant');
620
621 foreach ($values as $key => $val) {
622 if (in_array($val, $skipTokens)) {
623 continue;
624 }
625 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
626 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
627 $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
628 }
629 else {
630 $tokens["{participant.$val}"] = $exportFields[$val]['title'];
631 }
632 }
633 }
634 return $tokens;
635 }
636
637 /**
638 * CiviCRM supported date input formats
639 */
640 static function getDatePluginInputFormats() {
641 $dateInputFormats = array(
642 "mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'),
643 "dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'),
644 "yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'),
645 "dd-mm-yy" => ts('dd-mm-yyyy (31-12-2009)'),
646 'dd.mm.yy' => ts('dd.mm.yyyy (31.12.2009)'),
647 "M d, yy" => ts('M d, yyyy (Dec 31, 2009)'),
648 'd M yy' => ts('d M yyyy (31 Dec 2009)'),
649 "MM d, yy" => ts('MM d, yyyy (December 31, 2009)'),
650 'd MM yy' => ts('d MM yyyy (31 December 2009)'),
651 "DD, d MM yy" => ts('DD, d MM yyyy (Thursday, 31 December 2009)'),
652 "mm/dd" => ts('mm/dd (12/31)'),
653 "dd-mm" => ts('dd-mm (31-12)'),
654 "yy-mm" => ts('yyyy-mm (2009-12)'),
655 'M yy' => ts('M yyyy (Dec 2009)'),
656 "yy" => ts('yyyy (2009)'),
657 );
658
659 /*
660 Year greater than 2000 get wrong result for following format
661 echo date( 'Y-m-d', strtotime( '7 Nov, 2001') );
662 echo date( 'Y-m-d', strtotime( '7 November, 2001') );
663 Return current year
664 expected :: 2001-11-07
665 output :: 2009-11-07
666 However
667 echo date( 'Y-m-d', strtotime( 'Nov 7, 2001') );
668 echo date( 'Y-m-d', strtotime( 'November 7, 2001') );
669 gives proper result
670 */
671
672
673 return $dateInputFormats;
674 }
675
676 /**
677 * Map date plugin and actual format that is used by PHP
678 */
679 static function datePluginToPHPFormats() {
680 $dateInputFormats = array(
681 "mm/dd/yy" => 'm/d/Y',
682 "dd/mm/yy" => 'd/m/Y',
683 "yy-mm-dd" => 'Y-m-d',
684 "dd-mm-yy" => 'd-m-Y',
685 "dd.mm.yy" => 'd.m.Y',
686 "M d, yy" => 'M j, Y',
687 "d M yy" => 'j M Y',
688 "MM d, yy" => 'F j, Y',
689 "d MM yy" => 'j F Y',
690 "DD, d MM yy" => 'l, j F Y',
691 "mm/dd" => 'm/d',
692 "dd-mm" => 'd-m',
693 "yy-mm" => 'Y-m',
694 "M yy" => 'M Y',
695 "yy" => 'Y',
696 );
697 return $dateInputFormats;
698 }
699
700 /**
701 * Time formats
702 */
703 static function getTimeFormats() {
704 return array(
705 '1' => ts('12 Hours'),
706 '2' => ts('24 Hours'),
707 );
708 }
709
710 /**
711 * Function to get numeric options
712 *
713 *
714 * @static
715 */
716 public static function getNumericOptions($start = 0, $end = 10) {
717 $numericOptions = array();
718 for ($i = $start; $i <= $end; $i++) {
719 $numericOptions[$i] = $i;
720 }
721 return $numericOptions;
722 }
723
724 /**
725 * barcode types
726 * @static
727 */
728 static function getBarcodeTypes() {
729 return array(
730 'barcode' => ts('Linear (1D)'),
731 'qrcode' => ts('QR code'),
732 );
733 }
734
735 /**
736 * dedupe rule types
737 */
738 static function getDedupeRuleTypes() {
739 return array(
740 'Unsupervised' => ts('Unsupervised'),
741 'Supervised' => ts('Supervised'),
742 'General' => ts('General'),
743 );
744 }
745
746 /**
747 * campaign group types
748 */
749 static function getCampaignGroupTypes() {
750 return array(
751 'Include' => ts('Include'),
752 'Exclude' => ts('Exclude'),
753 );
754 }
755
756 /**
757 * subscription history method
758 */
759 static function getSubscriptionHistoryMethods() {
760 return array(
761 'Admin' => ts('Admin'),
762 'Email' => ts('Email'),
763 'Web' => ts('Web'),
764 'API' => ts('API'),
765 );
766 }
767
768 /**
769 * premium units
770 */
771 static function getPremiumUnits() {
772 return array(
773 'day' => ts('Day'),
774 'week' => ts('Week'),
775 'month' => ts('Month'),
776 'year' => ts('Year'),
777 );
778 }
779
780 /**
781 * extension types
782 */
783 static function getExtensionTypes() {
784 return array(
785 'payment' => ts('Payment'),
786 'search' => ts('Search'),
787 'report' => ts('Report'),
788 'module' => ts('Module'),
789 'sms' => ts('SMS'),
790 );
791 }
792
793 /**
794 * job frequency
795 */
796 static function getJobFrequency() {
797 return array(
798 'Daily' => ts('Daily'),
799 'Hourly' => ts('Hourly'),
800 'Always' => ts('Every time cron job is run'),
801 );
802 }
803
804 /**
805 * Search builder operators
806 */
807 static function getSearchBuilderOperators() {
808 return array(
809 '=' => '=',
810 '!=' => '≠',
811 '>' => '>',
812 '<' => '<',
813 '>=' => '≥',
814 '<=' => '≤',
815 'IN' => ts('In'),
816 'LIKE' => ts('Like'),
817 'RLIKE' => ts('Regex'),
818 'IS EMPTY' => ts('Is Empty'),
819 'IS NOT EMPTY' => ts('Not Empty'),
820 'IS NULL' => ts('Is Null'),
821 'IS NOT NULL' => ts('Not Null'),
822 );
823 }
824
825 /**
826 * profile group types
827 *
828 * @static
829 */
830 static function getProfileGroupType() {
831 $profileGroupType = array(
832 'Activity' => ts('Activities'),
833 'Contribution' => ts('Contributions'),
834 'Membership' => ts('Memberships'),
835 'Participant' => ts('Participants'),
836 );
837 $contactTypes = self::contactType();
838 $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
839 $profileGroupType = array_merge($contactTypes, $profileGroupType );
840
841 return $profileGroupType;
842 }
843
844
845 /**
846 * word replacement match type
847 */
848 static function getWordReplacementMatchType() {
849 return array(
850 'exactMatch' => ts('Exact Match'),
851 'wildcardMatch' => ts('Wildcard Match'),
852 );
853 }
854
855 /**
856 * mailing group types
857 */
858 static function getMailingGroupTypes() {
859 return array(
860 'Include' => ts('Include'),
861 'Exclude' => ts('Exclude'),
862 'Base' => ts('Base'),
863 );
864 }
865
866 /**
867 * Mailing Job Status
868 */
869 static function getMailingJobStatus() {
870 return array(
871 'Scheduled' => ts('Scheduled'),
872 'Running' => ts('Running'),
873 'Complete' => ts('Complete'),
874 'Paused' => ts('Paused'),
875 'Canceled' => ts('Canceled'),
876 );
877 }
878
879 static function billingMode() {
880 return array(
881 CRM_Core_Payment::BILLING_MODE_FORM => 'form',
882 CRM_Core_Payment::BILLING_MODE_BUTTON => 'button',
883 CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify',
884 );
885 }
886
887 /**
888 * Frequency unit for schedule reminders
889 */
890 static function getScheduleReminderFrequencyUnits() {
891 //@todo update schema to refer to option group direct & remove this
892 static $scheduleReminderFrequencyUnits = NULL;
893 if (!$scheduleReminderFrequencyUnits) {
894 $scheduleReminderFrequencyUnits = array(
895 'hour' => ts('hour')) + CRM_Core_OptionGroup::values('recur_frequency_units');
896 }
897
898 return $scheduleReminderFrequencyUnits;
899 }
900 }
901