Show correct CMS name for profile uf group types
[civicrm-core.git] / CRM / Core / SelectValues.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 use Civi\Token\TokenProcessor;
13
14 /**
15 * One place to store frequently used values in Select Elements. Note that
16 * some of the below elements will be dynamic, so we'll probably have a
17 * smart caching scheme on a per domain basis
18 *
19 * @package CRM
20 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 */
22 class CRM_Core_SelectValues {
23
24 /**
25 * Yes/No options
26 *
27 * @return array
28 */
29 public static function boolean() {
30 return [
31 1 => ts('Yes'),
32 0 => ts('No'),
33 ];
34 }
35
36 /**
37 * Preferred mail format.
38 *
39 * @return array
40 */
41 public static function pmf() {
42 return [
43 'Both' => ts('Both'),
44 'HTML' => ts('HTML'),
45 'Text' => ts('Text'),
46 ];
47 }
48
49 /**
50 * Privacy options.
51 *
52 * @return array
53 */
54 public static function privacy() {
55 return [
56 'do_not_phone' => ts('Do not phone'),
57 'do_not_email' => ts('Do not email'),
58 'do_not_mail' => ts('Do not mail'),
59 'do_not_sms' => ts('Do not sms'),
60 'do_not_trade' => ts('Do not trade'),
61 'is_opt_out' => ts('No bulk emails (User Opt Out)'),
62 ];
63 }
64
65 /**
66 * Various pre defined contact super types.
67 *
68 * @return array
69 */
70 public static function contactType() {
71 return CRM_Contact_BAO_ContactType::basicTypePairs();
72 }
73
74 /**
75 * Various pre defined unit list.
76 *
77 * @param string $unitType
78 * @return array
79 */
80 public static function unitList($unitType = NULL) {
81 $unitList = [
82 'day' => ts('day'),
83 'month' => ts('month'),
84 'year' => ts('year'),
85 ];
86 if ($unitType === 'duration') {
87 $unitList['lifetime'] = ts('lifetime');
88 }
89 return $unitList;
90 }
91
92 /**
93 * Membership type unit.
94 *
95 * @return array
96 */
97 public static function membershipTypeUnitList() {
98 return self::unitList('duration');
99 }
100
101 /**
102 * Various pre defined period types.
103 *
104 * @return array
105 */
106 public static function periodType() {
107 return [
108 'rolling' => ts('Rolling'),
109 'fixed' => ts('Fixed'),
110 ];
111 }
112
113 /**
114 * Various pre defined email selection methods.
115 *
116 * @return array
117 */
118 public static function emailSelectMethods() {
119 return [
120 'automatic' => ts('Automatic'),
121 'location-only' => ts('Only send to email addresses assigned to the specified location'),
122 'location-prefer' => ts('Prefer email addresses assigned to the specified location'),
123 'location-exclude' => ts('Exclude email addresses assigned to the specified location'),
124 ];
125 }
126
127 /**
128 * Various pre defined member visibility options.
129 *
130 * @return array
131 */
132 public static function memberVisibility() {
133 return [
134 'Public' => ts('Public'),
135 'Admin' => ts('Admin'),
136 ];
137 }
138
139 /**
140 * Member auto-renew options
141 *
142 * @return array
143 */
144 public static function memberAutoRenew() {
145 return [
146 ts('No auto-renew option'),
147 ts('Give option, but not required'),
148 ts('Auto-renew required'),
149 ];
150 }
151
152 /**
153 * Various pre defined event dates.
154 *
155 * @return array
156 */
157 public static function eventDate() {
158 return [
159 'start_date' => ts('start date'),
160 'end_date' => ts('end date'),
161 'join_date' => ts('member since'),
162 ];
163 }
164
165 /**
166 * Custom form field types.
167 *
168 * @return array
169 */
170 public static function customHtmlType() {
171 return [
172 'Text' => ts('Single-line input field (text or numeric)'),
173 'TextArea' => ts('Multi-line text box (textarea)'),
174 'Select' => ts('Drop-down (select list)'),
175 'Radio' => ts('Radio buttons'),
176 'CheckBox' => ts('Checkbox(es)'),
177 'Select Date' => ts('Select Date'),
178 'File' => ts('File'),
179 'RichTextEditor' => ts('Rich Text Editor'),
180 'Autocomplete-Select' => ts('Autocomplete-Select'),
181 'Link' => ts('Link'),
182 ];
183 }
184
185 /**
186 * Various pre defined extensions for dynamic properties and groups.
187 *
188 * @return array
189 *
190 */
191 public static function customGroupExtends() {
192 $customGroupExtends = [
193 'Activity' => ts('Activities'),
194 'Relationship' => ts('Relationships'),
195 'Contribution' => ts('Contributions'),
196 'ContributionRecur' => ts('Recurring Contributions'),
197 'Group' => ts('Groups'),
198 'Membership' => ts('Memberships'),
199 'Event' => ts('Events'),
200 'Participant' => ts('Participants'),
201 'ParticipantRole' => ts('Participants (Role)'),
202 'ParticipantEventName' => ts('Participants (Event Name)'),
203 'ParticipantEventType' => ts('Participants (Event Type)'),
204 'Pledge' => ts('Pledges'),
205 'Grant' => ts('Grants'),
206 'Address' => ts('Addresses'),
207 'Campaign' => ts('Campaigns'),
208 ];
209 $contactTypes = ['Contact' => ts('Contacts')] + self::contactType();
210 $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects');
211 $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs);
212 return $customGroupExtends;
213 }
214
215 /**
216 * Styles for displaying the custom data group.
217 *
218 * @return array
219 */
220 public static function customGroupStyle() {
221 return [
222 'Tab' => ts('Tab'),
223 'Inline' => ts('Inline'),
224 'Tab with table' => ts('Tab with table'),
225 ];
226 }
227
228 /**
229 * For displaying the uf group types.
230 *
231 * @return array
232 */
233 public static function ufGroupTypes() {
234 $ufGroupType = [
235 'Profile' => ts('Standalone Form or Directory'),
236 'Search Profile' => ts('Search Views'),
237 ];
238
239 if (CRM_Core_Config::singleton()->userSystem->supports_form_extensions) {
240 $ufGroupType += CRM_Core_Config::singleton()->userSystem->getUfGroupTypes();
241 }
242 return $ufGroupType;
243 }
244
245 /**
246 * The status of a contact within a group.
247 *
248 * @return array
249 */
250 public static function groupContactStatus() {
251 return [
252 'Added' => ts('Added'),
253 'Removed' => ts('Removed'),
254 'Pending' => ts('Pending'),
255 ];
256 }
257
258 /**
259 * List of Group Types.
260 *
261 * @return array
262 */
263 public static function groupType() {
264 return [
265 'query' => ts('Dynamic'),
266 'static' => ts('Static'),
267 ];
268 }
269
270 /**
271 * Compose the parameters for a date select object.
272 *
273 * @param string|null $type
274 * the type of date
275 * @param string|null $format
276 * date format (QF format)
277 * @param null $minOffset
278 * @param null $maxOffset
279 * @param string $context
280 *
281 * @return array
282 * the date array
283 * @throws CRM_Core_Exception
284 */
285 public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL, $context = 'display') {
286 // These options are deprecated. Definitely not used in datepicker. Possibly not even in jcalendar+addDateTime.
287 $date = [
288 'addEmptyOption' => TRUE,
289 'emptyOptionText' => ts('- select -'),
290 'emptyOptionValue' => '',
291 ];
292
293 if ($format) {
294 $date['format'] = $format;
295 }
296 else {
297 if ($type) {
298 $dao = new CRM_Core_DAO_PreferencesDate();
299 $dao->name = $type;
300 if (!$dao->find(TRUE)) {
301 throw new CRM_Core_Exception('Date preferences not configured.');
302 }
303 if (!$maxOffset) {
304 $maxOffset = $dao->end;
305 }
306 if (!$minOffset) {
307 $minOffset = $dao->start;
308 }
309
310 $date['format'] = $dao->date_format;
311 $date['time'] = (bool) $dao->time_format;
312 }
313
314 if (empty($date['format'])) {
315 if ($context === 'Input') {
316 $date['format'] = Civi::settings()->get('dateInputFormat');
317 }
318 else {
319 $date['format'] = 'M d';
320 }
321 }
322 }
323
324 $date['smarty_view_format'] = CRM_Utils_Date::getDateFieldViewFormat($date['format']);
325 if (!isset($date['time'])) {
326 $date['time'] = FALSE;
327 }
328
329 $year = date('Y');
330 $date['minYear'] = $year - (int) $minOffset;
331 $date['maxYear'] = $year + (int) $maxOffset;
332 return $date;
333 }
334
335 /**
336 * Values for UF form visibility options.
337 *
338 * @return array
339 */
340 public static function ufVisibility() {
341 return [
342 'User and User Admin Only' => ts('User and User Admin Only'),
343 'Public Pages' => ts('Expose Publicly'),
344 'Public Pages and Listings' => ts('Expose Publicly and for Listings'),
345 ];
346 }
347
348 /**
349 * Values for group form visibility options.
350 *
351 * @return array
352 */
353 public static function groupVisibility() {
354 return [
355 'User and User Admin Only' => ts('User and User Admin Only'),
356 'Public Pages' => ts('Public Pages'),
357 ];
358 }
359
360 /**
361 * Different type of Mailing Components.
362 *
363 * @return array
364 */
365 public static function mailingComponents() {
366 return [
367 'Header' => ts('Header'),
368 'Footer' => ts('Footer'),
369 'Reply' => ts('Reply Auto-responder'),
370 'OptOut' => ts('Opt-out Message'),
371 'Subscribe' => ts('Subscription Confirmation Request'),
372 'Welcome' => ts('Welcome Message'),
373 'Unsubscribe' => ts('Unsubscribe Message'),
374 'Resubscribe' => ts('Resubscribe Message'),
375 ];
376 }
377
378 /**
379 * Get hours.
380 *
381 * @return array
382 */
383 public function getHours() {
384 $hours = [];
385 for ($i = 0; $i <= 6; $i++) {
386 $hours[$i] = $i;
387 }
388 return $hours;
389 }
390
391 /**
392 * Get minutes.
393 *
394 * @return array
395 */
396 public function getMinutes() {
397 $minutes = [];
398 for ($i = 0; $i < 60; $i = $i + 15) {
399 $minutes[$i] = $i;
400 }
401 return $minutes;
402 }
403
404 /**
405 * Get the Map Provider.
406 *
407 * @return array
408 * array of map providers
409 */
410 public static function mapProvider() {
411 static $map = NULL;
412 if (!$map) {
413 $map = ['' => '- select -'] + CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl");
414 }
415 return $map;
416 }
417
418 /**
419 * Get the Geocoding Providers from available plugins.
420 *
421 * @return array
422 * array of geocoder providers
423 */
424 public static function geoProvider() {
425 static $geo = NULL;
426 if (!$geo) {
427 $geo = ['' => '- select -'] + CRM_Utils_System::getPluginList('CRM/Utils/Geocode');
428 }
429 return $geo;
430 }
431
432 /**
433 * Get options for displaying tax.
434 *
435 * @return array
436 *
437 * @throws \CRM_Core_Exception
438 */
439 public static function taxDisplayOptions() {
440 return [
441 'Do_not_show' => ts('Do not show breakdown, only show total - i.e %1', [
442 1 => CRM_Utils_Money::format(120),
443 ]),
444 'Inclusive' => ts('Show [tax term] inclusive price - i.e. %1', [
445 1 => ts('%1 (includes [tax term] of %2)', [1 => CRM_Utils_Money::format(120), 2 => CRM_Utils_Money::format(20)]),
446 ]),
447 'Exclusive' => ts('Show [tax term] exclusive price - i.e. %1', [
448 1 => ts('%1 + %2 [tax term]', [1 => CRM_Utils_Money::format(120), 2 => CRM_Utils_Money::format(20)]),
449 ]),
450 ];
451 }
452
453 /**
454 * Get the Address Standardization Providers from available plugins.
455 *
456 * @return array
457 * array of address standardization providers
458 */
459 public static function addressProvider() {
460 static $addr = NULL;
461 if (!$addr) {
462 $addr = array_merge(['' => '- select -'], CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', ['BatchUpdate']));
463 }
464 return $addr;
465 }
466
467 /**
468 * Different type of Mailing Tokens.
469 *
470 * @return array
471 */
472 public static function mailingTokens() {
473 return [
474 '{action.unsubscribe}' => ts('Unsubscribe via email'),
475 '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'),
476 '{action.resubscribe}' => ts('Resubscribe via email'),
477 '{action.resubscribeUrl}' => ts('Resubscribe via web page'),
478 '{action.optOut}' => ts('Opt out via email'),
479 '{action.optOutUrl}' => ts('Opt out via web page'),
480 '{action.forward}' => ts('Forward this email (link)'),
481 '{action.reply}' => ts('Reply to this email (link)'),
482 '{action.subscribeUrl}' => ts('Subscribe via web page'),
483 '{mailing.key}' => ts('Mailing key'),
484 '{mailing.name}' => ts('Mailing name'),
485 '{mailing.group}' => ts('Mailing group'),
486 '{mailing.viewUrl}' => ts('Mailing permalink'),
487 ] + self::domainTokens();
488 }
489
490 /**
491 * Domain tokens
492 *
493 * @return array
494 *
495 * @deprecated
496 */
497 public static function domainTokens() {
498 $tokenProcessor = new TokenProcessor(Civi::dispatcher(), []);
499 return $tokenProcessor->listTokens();
500 }
501
502 /**
503 * Different type of Activity Tokens.
504 *
505 * @return array
506 */
507 public static function activityTokens() {
508 return [
509 '{activity.activity_id}' => ts('Activity ID'),
510 '{activity.subject}' => ts('Activity Subject'),
511 '{activity.details}' => ts('Activity Details'),
512 '{activity.activity_date_time}' => ts('Activity Date Time'),
513 ];
514 }
515
516 /**
517 * Different type of Membership Tokens.
518 *
519 * @return array
520 */
521 public static function membershipTokens(): array {
522 return [
523 '{membership.id}' => ts('Membership ID'),
524 '{membership.status_id:label}' => ts('Status'),
525 '{membership.membership_type_id:label}' => ts('Membership Type'),
526 '{membership.start_date}' => ts('Membership Start Date'),
527 '{membership.join_date}' => ts('Member Since'),
528 '{membership.end_date}' => ts('Membership Expiration Date'),
529 '{membership.fee}' => ts('Membership Fee'),
530 ];
531 }
532
533 /**
534 * Different type of Event Tokens.
535 *
536 * @deprecated
537 *
538 * @return array
539 */
540 public static function eventTokens(): array {
541 $tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['eventId']]);
542 $allTokens = $tokenProcessor->listTokens();
543 foreach (array_keys($allTokens) as $token) {
544 if (strpos($token, '{domain.') === 0) {
545 unset($allTokens[$token]);
546 }
547 }
548 return $allTokens;
549 }
550
551 /**
552 * Different type of Contribution Tokens.
553 *
554 * @deprecated
555 *
556 * @return array
557 */
558 public static function contributionTokens(): array {
559 $tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['contributionId']]);
560 $allTokens = $tokenProcessor->listTokens();
561 foreach (array_keys($allTokens) as $token) {
562 if (strpos($token, '{domain.') === 0) {
563 unset($allTokens[$token]);
564 }
565 }
566 return $allTokens;
567 }
568
569 /**
570 * Different type of Contact Tokens.
571 *
572 * @deprecated
573 *
574 * @return array
575 */
576 public static function contactTokens(): array {
577 $tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['contactId']]);
578 $allTokens = $tokenProcessor->listTokens();
579 foreach (array_keys($allTokens) as $token) {
580 if (strpos($token, '{domain.') === 0) {
581 unset($allTokens[$token]);
582 }
583 }
584 return $allTokens;
585 }
586
587 /**
588 * Different type of Participant Tokens.
589 *
590 * @deprecated
591 *
592 * @return array
593 */
594 public static function participantTokens(): array {
595 $tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['participantId']]);
596 $allTokens = $tokenProcessor->listTokens();
597 foreach (array_keys($allTokens) as $token) {
598 if (strpos($token, '{domain.') === 0) {
599 unset($allTokens[$token]);
600 }
601 }
602 return $allTokens;
603 }
604
605 /**
606 * @param int $caseTypeId
607 * @return array
608 */
609 public static function caseTokens($caseTypeId = NULL) {
610 $tokens = [
611 '{case.id}' => ts('Case ID'),
612 '{case.case_type_id:label}' => ts('Case Type'),
613 '{case.subject}' => ts('Case Subject'),
614 '{case.start_date}' => ts('Case Start Date'),
615 '{case.end_date}' => ts('Case End Date'),
616 '{case.details}' => ts('Details'),
617 '{case.status_id:label}' => ts('Case Status'),
618 '{case.is_deleted:label}' => ts('Case is in the Trash'),
619 '{case.created_date}' => ts('Created Date'),
620 '{case.modified_date}' => ts('Modified Date'),
621 ];
622
623 $customFields = CRM_Core_BAO_CustomField::getFields('Case', FALSE, FALSE, $caseTypeId);
624 foreach ($customFields as $id => $field) {
625 $tokens["{case.custom_$id}"] = "{$field['label']} :: {$field['groupTitle']}";
626 }
627 return $tokens;
628 }
629
630 /**
631 * CiviCRM supported date input formats.
632 *
633 * @return array
634 */
635 public static function getDatePluginInputFormats() {
636 return [
637 'mm/dd/yy' => ts('mm/dd/yy (12/31/2009)'),
638 'dd/mm/yy' => ts('dd/mm/yy (31/12/2009)'),
639 'yy-mm-dd' => ts('yy-mm-dd (2009-12-31)'),
640 'dd-mm-yy' => ts('dd-mm-yy (31-12-2009)'),
641 'dd.mm.yy' => ts('dd.mm.yy (31.12.2009)'),
642 'M d, yy' => ts('M d, yy (Dec 31, 2009)'),
643 'd M yy' => ts('d M yy (31 Dec 2009)'),
644 'MM d, yy' => ts('MM d, yy (December 31, 2009)'),
645 'd MM yy' => ts('d MM yy (31 December 2009)'),
646 'DD, d MM yy' => ts('DD, d MM yy (Thursday, 31 December 2009)'),
647 'mm/dd' => ts('mm/dd (12/31)'),
648 'dd-mm' => ts('dd-mm (31-12)'),
649 'yy-mm' => ts('yy-mm (2009-12)'),
650 'M yy' => ts('M yy (Dec 2009)'),
651 'yy' => ts('yy (2009)'),
652 ];
653 }
654
655 /**
656 * Time formats.
657 *
658 * @return array
659 */
660 public static function getTimeFormats() {
661 return [
662 '1' => ts('12 Hours'),
663 '2' => ts('24 Hours'),
664 ];
665 }
666
667 /**
668 * Get numeric options.
669 *
670 * @param int $start
671 * @param int $end
672 *
673 * @return array
674 */
675 public static function getNumericOptions($start = 0, $end = 10) {
676 $numericOptions = [];
677 for ($i = $start; $i <= $end; $i++) {
678 $numericOptions[$i] = $i;
679 }
680 return $numericOptions;
681 }
682
683 /**
684 * Barcode types.
685 *
686 * @return array
687 */
688 public static function getBarcodeTypes() {
689 return [
690 'barcode' => ts('Linear (1D)'),
691 'qrcode' => ts('QR code'),
692 ];
693 }
694
695 /**
696 * Dedupe rule types.
697 *
698 * @return array
699 */
700 public static function getDedupeRuleTypes() {
701 return [
702 'Unsupervised' => ts('Unsupervised'),
703 'Supervised' => ts('Supervised'),
704 'General' => ts('General'),
705 ];
706 }
707
708 /**
709 * Campaign group types.
710 *
711 * @return array
712 */
713 public static function getCampaignGroupTypes() {
714 return [
715 'Include' => ts('Include'),
716 'Exclude' => ts('Exclude'),
717 ];
718 }
719
720 /**
721 * Subscription history method.
722 *
723 * @return array
724 */
725 public static function getSubscriptionHistoryMethods() {
726 return [
727 'Admin' => ts('Admin'),
728 'Email' => ts('Email'),
729 'Web' => ts('Web'),
730 'API' => ts('API'),
731 ];
732 }
733
734 /**
735 * Premium units.
736 *
737 * @return array
738 */
739 public static function getPremiumUnits() {
740 return [
741 'day' => ts('Day'),
742 'week' => ts('Week'),
743 'month' => ts('Month'),
744 'year' => ts('Year'),
745 ];
746 }
747
748 /**
749 * Extension types.
750 *
751 * @return array
752 */
753 public static function getExtensionTypes() {
754 return [
755 'payment' => ts('Payment'),
756 'search' => ts('Search'),
757 'report' => ts('Report'),
758 'module' => ts('Module'),
759 'sms' => ts('SMS'),
760 ];
761 }
762
763 /**
764 * Job frequency.
765 *
766 * @return array
767 */
768 public static function getJobFrequency() {
769 return [
770 // CRM-17669
771 'Yearly' => ts('Yearly'),
772 'Quarter' => ts('Quarterly'),
773 'Monthly' => ts('Monthly'),
774 'Weekly' => ts('Weekly'),
775
776 'Daily' => ts('Daily'),
777 'Hourly' => ts('Hourly'),
778 'Always' => ts('Every time cron job is run'),
779 ];
780 }
781
782 /**
783 * Search builder operators.
784 *
785 * @return array
786 */
787 public static function getSearchBuilderOperators() {
788 return [
789 '=' => '=',
790 '!=' => '≠',
791 '>' => '>',
792 '<' => '<',
793 '>=' => '≥',
794 '<=' => '≤',
795 'IN' => ts('In'),
796 'NOT IN' => ts('Not In'),
797 'LIKE' => ts('Like'),
798 'NOT LIKE' => ts('Not Like'),
799 'RLIKE' => ts('Regex'),
800 'IS EMPTY' => ts('Is Empty'),
801 'IS NOT EMPTY' => ts('Not Empty'),
802 'IS NULL' => ts('Is Null'),
803 'IS NOT NULL' => ts('Not Null'),
804 ];
805 }
806
807 /**
808 * Profile group types.
809 *
810 * @return array
811 */
812 public static function getProfileGroupType() {
813 $profileGroupType = [
814 'Activity' => ts('Activities'),
815 'Contribution' => ts('Contributions'),
816 'Membership' => ts('Memberships'),
817 'Participant' => ts('Participants'),
818 ];
819 $contactTypes = self::contactType();
820 $contactTypes = !empty($contactTypes) ? ['Contact' => 'Contacts'] + $contactTypes : [];
821 $profileGroupType = array_merge($contactTypes, $profileGroupType);
822
823 return $profileGroupType;
824 }
825
826 /**
827 * Word replacement match type.
828 *
829 * @return array
830 */
831 public static function getWordReplacementMatchType() {
832 return [
833 'exactMatch' => ts('Exact Match'),
834 'wildcardMatch' => ts('Wildcard Match'),
835 ];
836 }
837
838 /**
839 * Mailing group types.
840 *
841 * @return array
842 */
843 public static function getMailingGroupTypes() {
844 return [
845 'Include' => ts('Include'),
846 'Exclude' => ts('Exclude'),
847 'Base' => ts('Base'),
848 ];
849 }
850
851 /**
852 * Mailing Job Status.
853 *
854 * @return array
855 */
856 public static function getMailingJobStatus() {
857 return [
858 'Scheduled' => ts('Scheduled'),
859 'Running' => ts('Running'),
860 'Complete' => ts('Complete'),
861 'Paused' => ts('Paused'),
862 'Canceled' => ts('Canceled'),
863 ];
864 }
865
866 /**
867 * @return array
868 */
869 public static function billingMode() {
870 return [
871 CRM_Core_Payment::BILLING_MODE_FORM => 'form',
872 CRM_Core_Payment::BILLING_MODE_BUTTON => 'button',
873 CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify',
874 ];
875 }
876
877 /**
878 * @return array
879 */
880 public static function contributeMode() {
881 return [
882 CRM_Core_Payment::BILLING_MODE_FORM => 'direct',
883 CRM_Core_Payment::BILLING_MODE_BUTTON => 'directIPN',
884 CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify',
885 ];
886 }
887
888 /**
889 * Frequency unit for schedule reminders.
890 *
891 * @param int $count
892 * For pluralization
893 * @return array
894 */
895 public static function getRecurringFrequencyUnits($count = 1) {
896 // @todo this used to refer to the 'recur_frequency_unit' option_values which
897 // is for recurring payments and probably not good to re-use for recurring entities.
898 // If something other than a hard-coded list is desired, add a new option_group.
899 return [
900 'hour' => ts('hour', ['plural' => 'hours', 'count' => $count]),
901 'day' => ts('day', ['plural' => 'days', 'count' => $count]),
902 'week' => ts('week', ['plural' => 'weeks', 'count' => $count]),
903 'month' => ts('month', ['plural' => 'months', 'count' => $count]),
904 'year' => ts('year', ['plural' => 'years', 'count' => $count]),
905 ];
906 }
907
908 /**
909 * Relative Date Terms.
910 *
911 * @return array
912 */
913 public static function getRelativeDateTerms() {
914 return [
915 'previous' => ts('Previous'),
916 'previous_2' => ts('Previous 2'),
917 'previous_before' => ts('Prior to Previous'),
918 'before_previous' => ts('All Prior to Previous'),
919 'earlier' => ts('To End of Previous'),
920 'greater_previous' => ts('From End of Previous'),
921 'greater' => ts('From Start Of Current'),
922 'current' => ts('Current'),
923 'ending_3' => ts('Last 3'),
924 'ending_2' => ts('Last 2'),
925 'ending' => ts('Last'),
926 'this' => ts('This'),
927 'starting' => ts('Upcoming'),
928 'less' => ts('To End of'),
929 'next' => ts('Next'),
930 ];
931 }
932
933 /**
934 * Relative Date Units.
935 *
936 * @return array
937 */
938 public static function getRelativeDateUnits() {
939 return [
940 'year' => ts('Years'),
941 'fiscal_year' => ts('Fiscal Years'),
942 'quarter' => ts('Quarters'),
943 'month' => ts('Months'),
944 'week' => ts('Weeks'),
945 'day' => ts('Days'),
946 ];
947 }
948
949 /**
950 * Exportable document formats.
951 *
952 * @return array
953 */
954 public static function documentFormat() {
955 return [
956 'pdf' => ts('Portable Document Format (.pdf)'),
957 'docx' => ts('MS Word (.docx)'),
958 'odt' => ts('Open Office (.odt)'),
959 'html' => ts('Webpage (.html)'),
960 ];
961 }
962
963 /**
964 * Application type of document.
965 *
966 * @return array
967 */
968 public static function documentApplicationType() {
969 return [
970 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
971 'odt' => 'application/vnd.oasis.opendocument.text',
972 ];
973 }
974
975 /**
976 * Activity Text options.
977 *
978 * @return array
979 */
980 public static function activityTextOptions() {
981 return [
982 2 => ts('Details Only'),
983 3 => ts('Subject Only'),
984 6 => ts('Both'),
985 ];
986 }
987
988 /**
989 * Relationship permissions
990 *
991 * @return array
992 */
993 public static function getPermissionedRelationshipOptions() {
994 return [
995 CRM_Contact_BAO_Relationship::NONE => ts('None'),
996 CRM_Contact_BAO_Relationship::VIEW => ts('View only'),
997 CRM_Contact_BAO_Relationship::EDIT => ts('View and update'),
998 ];
999 }
1000
1001 /**
1002 * Get option values for dashboard entries (used for 'how many events to display on dashboard').
1003 *
1004 * @return array
1005 * Dashboard entries options - in practice [-1 => 'Show All', 10 => 10, 20 => 20, ... 100 => 100].
1006 */
1007 public static function getDashboardEntriesCount() {
1008 $optionValues = [];
1009 $optionValues[-1] = ts('show all');
1010 for ($i = 10; $i <= 100; $i += 10) {
1011 $optionValues[$i] = $i;
1012 }
1013 return $optionValues;
1014 }
1015
1016 /**
1017 * Dropdown options for quicksearch in the menu
1018 *
1019 * @return array
1020 * @throws \CiviCRM_API3_Exception
1021 */
1022 public static function quicksearchOptions() {
1023 $includeEmail = civicrm_api3('setting', 'getvalue', ['name' => 'includeEmailInName', 'group' => 'Search Preferences']);
1024 $options = [
1025 'sort_name' => $includeEmail ? ts('Name/Email') : ts('Name'),
1026 'contact_id' => ts('Contact ID'),
1027 'external_identifier' => ts('External ID'),
1028 'first_name' => ts('First Name'),
1029 'last_name' => ts('Last Name'),
1030 'email' => ts('Email'),
1031 'phone_numeric' => ts('Phone'),
1032 'street_address' => ts('Street Address'),
1033 'city' => ts('City'),
1034 'postal_code' => ts('Postal Code'),
1035 'job_title' => ts('Job Title'),
1036 ];
1037 $custom = civicrm_api3('CustomField', 'get', [
1038 'return' => ['name', 'label', 'custom_group_id.title'],
1039 'custom_group_id.extends' => ['IN' => ['Contact', 'Individual', 'Organization', 'Household']],
1040 'data_type' => ['NOT IN' => ['ContactReference', 'Date', 'File']],
1041 'custom_group_id.is_active' => 1,
1042 'is_active' => 1,
1043 'is_searchable' => 1,
1044 'options' => ['sort' => ['custom_group_id.weight', 'weight'], 'limit' => 0],
1045 ]);
1046 foreach ($custom['values'] as $field) {
1047 $options['custom_' . $field['name']] = $field['custom_group_id.title'] . ': ' . $field['label'];
1048 }
1049 return $options;
1050 }
1051
1052 /**
1053 * Get components (translated for display.
1054 *
1055 * @return array
1056 *
1057 * @throws \Exception
1058 */
1059 public static function getComponentSelectValues() {
1060 $ret = [];
1061 $components = CRM_Core_Component::getComponents();
1062 foreach ($components as $name => $object) {
1063 $ret[$name] = $object->info['translatedName'];
1064 }
1065
1066 return $ret;
1067 }
1068
1069 /**
1070 * @return string[]
1071 */
1072 public static function fieldSerialization() {
1073 return [
1074 CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND => 'separator_bookend',
1075 CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED => 'separator_trimmed',
1076 CRM_Core_DAO::SERIALIZE_JSON => 'json',
1077 CRM_Core_DAO::SERIALIZE_PHP => 'php',
1078 CRM_Core_DAO::SERIALIZE_COMMA => 'comma',
1079 ];
1080 }
1081
1082 /**
1083 * @return array
1084 */
1085 public static function navigationMenuSeparator() {
1086 return [
1087 ts('None'),
1088 ts('After menu element'),
1089 ts('Before menu element'),
1090 ];
1091 }
1092
1093 /**
1094 * @return array
1095 */
1096 public static function relationshipOrientation() {
1097 return [
1098 'a_b' => ts('A to B'),
1099 'b_a' => ts('B to A'),
1100 ];
1101 }
1102
1103 }