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