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