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