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