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