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