Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | |
06b69b18 | 34 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
35 | * $Id$ |
36 | * | |
37 | */ | |
38 | class CRM_Core_SelectValues { | |
39 | ||
6a488035 | 40 | /** |
f9e31d7f | 41 | * Preferred mail format. |
79d7553f | 42 | * |
76e7a76c | 43 | * @return array |
6a488035 | 44 | */ |
00be9182 | 45 | public static function pmf() { |
6795600d CW |
46 | return array( |
47 | 'Both' => ts('Both'), | |
48 | 'HTML' => ts('HTML'), | |
49 | 'Text' => ts('Text'), | |
50 | ); | |
6a488035 TO |
51 | } |
52 | ||
53 | /** | |
f9e31d7f | 54 | * Privacy options. |
76e7a76c CW |
55 | * |
56 | * @return array | |
6a488035 | 57 | */ |
00be9182 | 58 | public static function privacy() { |
6795600d CW |
59 | return array( |
60 | 'do_not_phone' => ts('Do not phone'), | |
61 | 'do_not_email' => ts('Do not email'), | |
62 | 'do_not_mail' => ts('Do not mail'), | |
63 | 'do_not_sms' => ts('Do not sms'), | |
64 | 'do_not_trade' => ts('Do not trade'), | |
65 | 'is_opt_out' => ts('No bulk emails (User Opt Out)'), | |
66 | ); | |
6a488035 TO |
67 | } |
68 | ||
69 | /** | |
f9e31d7f | 70 | * Various pre defined contact super types. |
76e7a76c CW |
71 | * |
72 | * @return array | |
6a488035 | 73 | */ |
00be9182 | 74 | public static function contactType() { |
6a488035 TO |
75 | static $contactType = NULL; |
76 | if (!$contactType) { | |
694e78fd | 77 | $contactType = CRM_Contact_BAO_ContactType::basicTypePairs(); |
6a488035 TO |
78 | } |
79 | return $contactType; | |
80 | } | |
81 | ||
82 | /** | |
f9e31d7f | 83 | * Various pre defined unit list. |
79d7553f | 84 | * |
76e7a76c CW |
85 | * @param string $unitType |
86 | * @return array | |
6a488035 | 87 | */ |
00be9182 | 88 | public static function unitList($unitType = NULL) { |
c3831ebd EM |
89 | $unitList = array( |
90 | 'day' => ts('day'), | |
91 | 'month' => ts('month'), | |
92 | 'year' => ts('year'), | |
93 | ); | |
94 | if ($unitType == 'duration') { | |
6795600d | 95 | $unitList['lifetime'] = ts('lifetime'); |
6a488035 TO |
96 | } |
97 | return $unitList; | |
98 | } | |
99 | ||
93bfa565 | 100 | /** |
f9e31d7f | 101 | * Membership type unit. |
76e7a76c CW |
102 | * |
103 | * @return array | |
93bfa565 | 104 | */ |
2aa397bc | 105 | public static function membershipTypeUnitList() { |
6795600d | 106 | return self::unitList('duration'); |
93bfa565 | 107 | } |
108 | ||
6a488035 | 109 | /** |
f9e31d7f | 110 | * Various pre defined period types. |
76e7a76c CW |
111 | * |
112 | * @return array | |
6a488035 | 113 | */ |
00be9182 | 114 | public static function periodType() { |
c3831ebd EM |
115 | return array( |
116 | 'rolling' => ts('Rolling'), | |
117 | 'fixed' => ts('Fixed'), | |
118 | ); | |
6a488035 TO |
119 | } |
120 | ||
bac4cd35 | 121 | /** |
f9e31d7f | 122 | * Various pre defined email selection methods. |
76e7a76c CW |
123 | * |
124 | * @return array | |
bac4cd35 | 125 | */ |
00be9182 | 126 | public static function emailSelectMethods() { |
bac4cd35 | 127 | return array( |
128 | 'automatic' => ts("Automatic"), | |
129 | 'location-only' => ts("Only send to email addresses assigned to the specified location"), | |
130 | 'location-prefer' => ts("Prefer email addresses assigned to the specified location"), | |
21dfd5f5 | 131 | 'location-exclude' => ts("Exclude email addresses assigned to the specified location"), |
bac4cd35 | 132 | ); |
133 | } | |
134 | ||
6a488035 | 135 | /** |
f9e31d7f | 136 | * Various pre defined member visibility options. |
76e7a76c CW |
137 | * |
138 | * @return array | |
6a488035 | 139 | */ |
00be9182 | 140 | public static function memberVisibility() { |
ab5e0c41 CW |
141 | return array( |
142 | 'Public' => ts('Public'), | |
143 | 'Admin' => ts('Admin'), | |
144 | ); | |
6a488035 TO |
145 | } |
146 | ||
dbd82592 CW |
147 | /** |
148 | * Member auto-renew options | |
76e7a76c CW |
149 | * |
150 | * @return array | |
dbd82592 CW |
151 | */ |
152 | public static function memberAutoRenew() { | |
153 | return array( | |
154 | ts('No auto-renew option'), | |
155 | ts('Give option, but not required'), | |
21dfd5f5 | 156 | ts('Auto-renew required'), |
dbd82592 CW |
157 | ); |
158 | } | |
159 | ||
6a488035 | 160 | /** |
f9e31d7f | 161 | * Various pre defined event dates. |
76e7a76c CW |
162 | * |
163 | * @return array | |
6a488035 | 164 | */ |
00be9182 | 165 | public static function eventDate() { |
c3831ebd EM |
166 | return array( |
167 | 'start_date' => ts('start date'), | |
168 | 'end_date' => ts('end date'), | |
169 | 'join_date' => ts('member since'), | |
170 | ); | |
6a488035 TO |
171 | } |
172 | ||
6a488035 | 173 | /** |
f9e31d7f | 174 | * Custom form field types. |
76e7a76c CW |
175 | * |
176 | * @return array | |
6a488035 | 177 | */ |
00be9182 | 178 | public static function customHtmlType() { |
c3831ebd EM |
179 | return array( |
180 | 'Text' => ts('Single-line input field (text or numeric)'), | |
181 | 'TextArea' => ts('Multi-line text box (textarea)'), | |
182 | 'Select' => ts('Drop-down (select list)'), | |
183 | 'Radio' => ts('Radio buttons'), | |
184 | 'CheckBox' => ts('Checkbox(es)'), | |
185 | 'Select Date' => ts('Select Date'), | |
186 | 'File' => ts('File'), | |
187 | 'Select State/Province' => ts('Select State/Province'), | |
188 | 'Multi-Select State/Province' => ts('Multi-Select State/Province'), | |
189 | 'Select Country' => ts('Select Country'), | |
190 | 'Multi-Select Country' => ts('Multi-Select Country'), | |
191 | 'RichTextEditor' => ts('Rich Text Editor'), | |
192 | 'Autocomplete-Select' => ts('Autocomplete-Select'), | |
193 | 'Multi-Select' => ts('Multi-Select'), | |
194 | 'AdvMulti-Select' => ts('AdvMulti-Select'), | |
195 | 'Link' => ts('Link'), | |
79dc94e4 | 196 | 'ContactReference' => ts('Autocomplete-Select'), |
c3831ebd | 197 | ); |
6a488035 TO |
198 | } |
199 | ||
200 | /** | |
f9e31d7f | 201 | * Various pre defined extensions for dynamic properties and groups. |
6a488035 | 202 | * |
76e7a76c CW |
203 | * @return array |
204 | * | |
6a488035 | 205 | */ |
00be9182 | 206 | public static function customGroupExtends() { |
c3831ebd EM |
207 | $customGroupExtends = array( |
208 | 'Activity' => ts('Activities'), | |
209 | 'Relationship' => ts('Relationships'), | |
210 | 'Contribution' => ts('Contributions'), | |
211 | 'Group' => ts('Groups'), | |
212 | 'Membership' => ts('Memberships'), | |
213 | 'Event' => ts('Events'), | |
214 | 'Participant' => ts('Participants'), | |
215 | 'ParticipantRole' => ts('Participants (Role)'), | |
216 | 'ParticipantEventName' => ts('Participants (Event Name)'), | |
217 | 'ParticipantEventType' => ts('Participants (Event Type)'), | |
218 | 'Pledge' => ts('Pledges'), | |
219 | 'Grant' => ts('Grants'), | |
220 | 'Address' => ts('Addresses'), | |
221 | 'Campaign' => ts('Campaigns'), | |
222 | ); | |
223 | $contactTypes = self::contactType(); | |
6795600d CW |
224 | $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); |
225 | $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects'); | |
c3831ebd | 226 | $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs); |
6a488035 TO |
227 | return $customGroupExtends; |
228 | } | |
229 | ||
230 | /** | |
f9e31d7f | 231 | * Styles for displaying the custom data group. |
6a488035 | 232 | * |
76e7a76c CW |
233 | * @return array |
234 | * | |
6a488035 | 235 | */ |
00be9182 | 236 | public static function customGroupStyle() { |
c3831ebd EM |
237 | return array( |
238 | 'Tab' => ts('Tab'), | |
239 | 'Inline' => ts('Inline'), | |
240 | 'Tab with table' => ts('Tab with table'), | |
241 | ); | |
6a488035 TO |
242 | } |
243 | ||
244 | /** | |
f9e31d7f | 245 | * For displaying the uf group types. |
6a488035 | 246 | * |
76e7a76c | 247 | * @return array |
6a488035 | 248 | */ |
00be9182 | 249 | public static function ufGroupTypes() { |
c3831ebd EM |
250 | $ufGroupType = array( |
251 | 'Profile' => ts('Standalone Form or Directory'), | |
252 | 'Search Profile' => ts('Search Views'), | |
253 | ); | |
254 | ||
255 | if (CRM_Core_Config::singleton()->userSystem->supports_form_extensions) { | |
256 | $ufGroupType += array( | |
257 | 'User Registration' => ts('Drupal User Registration'), | |
258 | 'User Account' => ts('View/Edit Drupal User Account'), | |
6a488035 | 259 | ); |
6a488035 TO |
260 | } |
261 | return $ufGroupType; | |
262 | } | |
263 | ||
264 | /** | |
f9e31d7f | 265 | * The status of a contact within a group. |
6a488035 | 266 | * |
76e7a76c CW |
267 | * @return array |
268 | * | |
6a488035 | 269 | */ |
00be9182 | 270 | public static function groupContactStatus() { |
c3831ebd EM |
271 | return array( |
272 | 'Added' => ts('Added'), | |
273 | 'Removed' => ts('Removed'), | |
274 | 'Pending' => ts('Pending'), | |
275 | ); | |
6a488035 TO |
276 | } |
277 | ||
278 | /** | |
f9e31d7f | 279 | * List of Group Types. |
76e7a76c CW |
280 | * |
281 | * @return array | |
6a488035 | 282 | */ |
00be9182 | 283 | public static function groupType() { |
c3831ebd EM |
284 | return array( |
285 | 'query' => ts('Dynamic'), | |
286 | 'static' => ts('Static'), | |
287 | ); | |
6a488035 TO |
288 | } |
289 | ||
290 | /** | |
f9e31d7f | 291 | * Compose the parameters for a date select object. |
6a488035 | 292 | * |
76e7a76c CW |
293 | * @param string|NULL $type |
294 | * the type of date | |
295 | * @param string|NULL $format | |
296 | * date format (QF format) | |
9bf2a591 EM |
297 | * @param null $minOffset |
298 | * @param null $maxOffset | |
6a488035 | 299 | * |
a6c01b45 CW |
300 | * @return array |
301 | * the date array | |
6a488035 | 302 | */ |
00be9182 | 303 | public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) { |
6a488035 TO |
304 | $date = array( |
305 | 'addEmptyOption' => TRUE, | |
306 | 'emptyOptionText' => ts('- select -'), | |
307 | 'emptyOptionValue' => '', | |
308 | ); | |
309 | ||
310 | if ($format) { | |
311 | $date['format'] = $format; | |
312 | } | |
313 | else { | |
314 | if ($type) { | |
315 | $dao = new CRM_Core_DAO_PreferencesDate(); | |
316 | $dao->name = $type; | |
317 | if (!$dao->find(TRUE)) { | |
318 | CRM_Core_Error::fatal(); | |
319 | } | |
320 | } | |
321 | ||
322 | if ($type == 'creditCard') { | |
323 | $minOffset = $dao->start; | |
324 | $maxOffset = $dao->end; | |
325 | $date['format'] = $dao->date_format; | |
326 | $date['addEmptyOption'] = TRUE; | |
327 | $date['emptyOptionText'] = ts('- select -'); | |
328 | $date['emptyOptionValue'] = ''; | |
329 | } | |
330 | ||
a7488080 | 331 | if (empty($date['format'])) { |
6a488035 TO |
332 | $date['format'] = 'M d'; |
333 | } | |
334 | } | |
335 | ||
6795600d | 336 | $year = date('Y'); |
6a488035 TO |
337 | $date['minYear'] = $year - $minOffset; |
338 | $date['maxYear'] = $year + $maxOffset; | |
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() { |
c3831ebd EM |
348 | return array( |
349 | 'User and User Admin Only' => ts('User and User Admin Only'), | |
350 | 'Public Pages' => ts('Public Pages'), | |
351 | 'Public Pages and Listings' => ts('Public Pages and Listings'), | |
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() { |
c3831ebd | 361 | return array( |
6795600d CW |
362 | 'User and User Admin Only' => ts('User and User Admin Only'), |
363 | 'Public Pages' => ts('Public Pages'), | |
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() { |
2aa397bc | 373 | return array( |
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'), | |
382 | ); | |
6a488035 TO |
383 | } |
384 | ||
385 | /** | |
f9e31d7f | 386 | * Get hours. |
6a488035 | 387 | * |
76e7a76c | 388 | * @return array |
6a488035 | 389 | */ |
00be9182 | 390 | public function getHours() { |
9fab6f51 | 391 | $hours = array(); |
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() { |
9fab6f51 | 404 | $minutes = array(); |
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) { | |
6795600d | 420 | $map = 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) { | |
6795600d | 434 | $geo = CRM_Utils_System::getPluginList('CRM/Utils/Geocode'); |
6a488035 TO |
435 | } |
436 | return $geo; | |
437 | } | |
438 | ||
439 | /** | |
f9e31d7f | 440 | * Get the Address Standardization Providers from available plugins. |
6a488035 | 441 | * |
a6c01b45 CW |
442 | * @return array |
443 | * array of address standardization providers | |
6a488035 | 444 | */ |
00be9182 | 445 | public static function addressProvider() { |
6a488035 TO |
446 | static $addr = NULL; |
447 | if (!$addr) { | |
6795600d | 448 | $addr = CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate')); |
6a488035 TO |
449 | } |
450 | return $addr; | |
451 | } | |
452 | ||
453 | /** | |
f9e31d7f | 454 | * Different type of Mailing Tokens. |
6a488035 | 455 | * |
76e7a76c | 456 | * @return array |
6a488035 | 457 | */ |
00be9182 | 458 | public static function mailingTokens() { |
c3831ebd EM |
459 | return array( |
460 | '{action.unsubscribe}' => ts('Unsubscribe via email'), | |
461 | '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'), | |
462 | '{action.resubscribe}' => ts('Resubscribe via email'), | |
463 | '{action.resubscribeUrl}' => ts('Resubscribe via web page'), | |
464 | '{action.optOut}' => ts('Opt out via email'), | |
465 | '{action.optOutUrl}' => ts('Opt out via web page'), | |
466 | '{action.forward}' => ts('Forward this email (link)'), | |
467 | '{action.reply}' => ts('Reply to this email (link)'), | |
468 | '{action.subscribeUrl}' => ts('Subscribe via web page'), | |
469 | '{domain.name}' => ts('Domain name'), | |
470 | '{domain.address}' => ts('Domain (organization) address'), | |
471 | '{domain.phone}' => ts('Domain (organization) phone'), | |
472 | '{domain.email}' => ts('Domain (organization) email'), | |
473 | '{mailing.name}' => ts('Mailing name'), | |
474 | '{mailing.group}' => ts('Mailing group'), | |
475 | '{mailing.viewUrl}' => ts('Mailing permalink'), | |
476 | ); | |
6a488035 TO |
477 | } |
478 | ||
479 | /** | |
f9e31d7f | 480 | * Different type of Activity Tokens. |
6a488035 | 481 | * |
76e7a76c | 482 | * @return array |
6a488035 | 483 | */ |
00be9182 | 484 | public static function activityTokens() { |
c3831ebd EM |
485 | return array( |
486 | '{activity.activity_id}' => ts('Activity ID'), | |
487 | '{activity.subject}' => ts('Activity Subject'), | |
488 | '{activity.details}' => ts('Activity Details'), | |
489 | '{activity.activity_date_time}' => ts('Activity Date Time'), | |
490 | ); | |
6a488035 TO |
491 | } |
492 | ||
493 | /** | |
f9e31d7f | 494 | * Different type of Membership Tokens. |
6a488035 | 495 | * |
76e7a76c | 496 | * @return array |
6a488035 | 497 | */ |
00be9182 | 498 | public static function membershipTokens() { |
c3831ebd EM |
499 | return array( |
500 | '{membership.id}' => ts('Membership ID'), | |
501 | '{membership.status}' => ts('Membership Status'), | |
502 | '{membership.type}' => ts('Membership Type'), | |
503 | '{membership.start_date}' => ts('Membership Start Date'), | |
504 | '{membership.join_date}' => ts('Membership Join Date'), | |
505 | '{membership.end_date}' => ts('Membership End Date'), | |
506 | '{membership.fee}' => ts('Membership Fee'), | |
507 | ); | |
6a488035 TO |
508 | } |
509 | ||
510 | /** | |
f9e31d7f | 511 | * Different type of Event Tokens. |
6a488035 | 512 | * |
76e7a76c | 513 | * @return array |
6a488035 | 514 | */ |
00be9182 | 515 | public static function eventTokens() { |
c3831ebd EM |
516 | return array( |
517 | '{event.event_id}' => ts('Event ID'), | |
518 | '{event.title}' => ts('Event Title'), | |
519 | '{event.start_date}' => ts('Event Start Date'), | |
520 | '{event.end_date}' => ts('Event End Date'), | |
521 | '{event.event_type}' => ts('Event Type'), | |
522 | '{event.summary}' => ts('Event Summary'), | |
523 | '{event.contact_email}' => ts('Event Contact Email'), | |
524 | '{event.contact_phone}' => ts('Event Contact Phone'), | |
525 | '{event.description}' => ts('Event Description'), | |
526 | '{event.location}' => ts('Event Location'), | |
527 | '{event.fee_amount}' => ts('Event Fees'), | |
528 | '{event.info_url}' => ts('Event Info URL'), | |
529 | '{event.registration_url}' => ts('Event Registration URL'), | |
21dfd5f5 | 530 | '{event.balance}' => ts('Event Balance'), |
c3831ebd | 531 | ); |
6a488035 TO |
532 | } |
533 | ||
534 | /** | |
f9e31d7f | 535 | * Different type of Event Tokens. |
6a488035 | 536 | * |
76e7a76c | 537 | * @return array |
6a488035 | 538 | */ |
00be9182 | 539 | public static function contributionTokens() { |
c3831ebd EM |
540 | return array( |
541 | '{contribution.contribution_id}' => ts('Contribution ID'), | |
542 | '{contribution.total_amount}' => ts('Total Amount'), | |
543 | '{contribution.fee_amount}' => ts('Fee Amount'), | |
544 | '{contribution.net_amount}' => ts('Net Amount'), | |
c94fc35e | 545 | '{contribution.non_deductible_amount}' => ts('Non-deductible Amount'), |
c3831ebd EM |
546 | '{contribution.receive_date}' => ts('Contribution Receive Date'), |
547 | '{contribution.payment_instrument}' => ts('Payment Instrument'), | |
548 | '{contribution.trxn_id}' => ts('Transaction ID'), | |
549 | '{contribution.invoice_id}' => ts('Invoice ID'), | |
550 | '{contribution.currency}' => ts('Currency'), | |
551 | '{contribution.cancel_date}' => ts('Contribution Cancel Date'), | |
552 | '{contribution.cancel_reason}' => ts('Contribution Cancel Reason'), | |
553 | '{contribution.receipt_date}' => ts('Receipt Date'), | |
554 | '{contribution.thankyou_date}' => ts('Thank You Date'), | |
555 | '{contribution.contribution_source}' => ts('Contribution Source'), | |
556 | '{contribution.amount_level}' => ts('Amount Level'), | |
557 | //'{contribution.contribution_recur_id}' => ts('Contribution Recurring ID'), | |
558 | //'{contribution.honor_contact_id}' => ts('Honor Contact ID'), | |
559 | '{contribution.contribution_status_id}' => ts('Contribution Status'), | |
560 | //'{contribution.honor_type_id}' => ts('Honor Type ID'), | |
561 | //'{contribution.address_id}' => ts('Address ID'), | |
562 | '{contribution.check_number}' => ts('Check Number'), | |
563 | '{contribution.campaign}' => ts('Contribution Campaign'), | |
564 | ); | |
6a488035 TO |
565 | } |
566 | ||
567 | /** | |
f9e31d7f | 568 | * Different type of Contact Tokens. |
6a488035 | 569 | * |
76e7a76c | 570 | * @return array |
6a488035 | 571 | */ |
00be9182 | 572 | public static function contactTokens() { |
6a488035 TO |
573 | static $tokens = NULL; |
574 | if (!$tokens) { | |
2aa397bc | 575 | $additionalFields = array( |
353ffa53 | 576 | 'checksum' => array('title' => ts('Checksum')), |
6a488035 TO |
577 | 'contact_id' => array('title' => ts('Internal Contact ID')), |
578 | ); | |
579 | $exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields); | |
580 | ||
581 | $values = array_merge(array_keys($exportFields)); | |
582 | unset($values[0]); | |
583 | ||
584 | //FIXME:skipping some tokens for time being. | |
585 | $skipTokens = array( | |
353ffa53 TO |
586 | 'is_bulkmail', |
587 | 'group', | |
588 | 'tag', | |
589 | 'contact_sub_type', | |
590 | 'note', | |
591 | 'is_deceased', | |
592 | 'deceased_date', | |
593 | 'legal_identifier', | |
594 | 'contact_sub_type', | |
595 | 'user_unique_id', | |
6a488035 | 596 | ); |
ea921622 | 597 | |
72e34731 | 598 | $customFields = CRM_Core_BAO_CustomField::getFields(array('Individual', 'Address')); |
cc615373 | 599 | $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens()); |
6a488035 | 600 | |
cc615373 | 601 | foreach ($values as $val) { |
6a488035 TO |
602 | if (in_array($val, $skipTokens)) { |
603 | continue; | |
604 | } | |
605 | //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734 | |
72e34731 CW |
606 | $customFieldId = CRM_Core_BAO_CustomField::getKeyID($val); |
607 | if ($customFieldId) { | |
608 | // CRM-15191 - if key is not in $customFields then the field is disabled and should be ignored | |
609 | if (!empty($customFields[$customFieldId])) { | |
610 | $tokens["{contact.$val}"] = $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle']; | |
611 | } | |
6a488035 TO |
612 | } |
613 | else { | |
cc615373 CW |
614 | // Support legacy token names |
615 | $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val); | |
616 | $tokens["{contact.$tokenName}"] = $exportFields[$val]['title']; | |
6a488035 TO |
617 | } |
618 | } | |
619 | ||
9950a1c9 | 620 | // Get all the hook tokens too |
6a488035 TO |
621 | $hookTokens = array(); |
622 | CRM_Utils_Hook::tokens($hookTokens); | |
94bf1070 | 623 | foreach ($hookTokens as $tokenValues) { |
6a488035 TO |
624 | foreach ($tokenValues as $key => $value) { |
625 | if (is_numeric($key)) { | |
626 | $key = $value; | |
627 | } | |
628 | if (!preg_match('/^\{[^\}]+\}$/', $key)) { | |
629 | $key = '{' . $key . '}'; | |
630 | } | |
631 | if (preg_match('/^\{([^\}]+)\}$/', $value, $matches)) { | |
632 | $value = $matches[1]; | |
633 | } | |
634 | $tokens[$key] = $value; | |
635 | } | |
636 | } | |
637 | } | |
638 | ||
639 | return $tokens; | |
640 | } | |
641 | ||
ea921622 | 642 | /** |
f9e31d7f | 643 | * Different type of Participant Tokens. |
ea921622 | 644 | * |
76e7a76c | 645 | * @return array |
ea921622 | 646 | */ |
00be9182 | 647 | public static function participantTokens() { |
ea921622 KJ |
648 | static $tokens = NULL; |
649 | if (!$tokens) { | |
650 | $exportFields = CRM_Event_BAO_Participant::exportableFields(); | |
651 | ||
652 | $values = array_merge(array_keys($exportFields)); | |
653 | unset($values[0]); | |
654 | ||
655 | // skipping some tokens for time being. | |
656 | $skipTokens = array( | |
353ffa53 TO |
657 | 'event_id', |
658 | 'participant_is_pay_later', | |
659 | 'participant_is_test', | |
660 | 'participant_contact_id', | |
661 | 'participant_fee_currency', | |
662 | 'participant_campaign_id', | |
663 | 'participant_status', | |
664 | 'participant_discount_name', | |
ea921622 KJ |
665 | ); |
666 | ||
667 | $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); | |
668 | ||
669 | foreach ($values as $key => $val) { | |
670 | if (in_array($val, $skipTokens)) { | |
671 | continue; | |
672 | } | |
673 | //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734 | |
674 | if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) { | |
0d8afee2 | 675 | $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : ''; |
ea921622 KJ |
676 | } |
677 | else { | |
678 | $tokens["{participant.$val}"] = $exportFields[$val]['title']; | |
679 | } | |
680 | } | |
681 | } | |
682 | return $tokens; | |
683 | } | |
684 | ||
6a488035 | 685 | /** |
f9e31d7f | 686 | * CiviCRM supported date input formats. |
76e7a76c CW |
687 | * |
688 | * @return array | |
6a488035 | 689 | */ |
00be9182 | 690 | public static function getDatePluginInputFormats() { |
6a488035 TO |
691 | $dateInputFormats = array( |
692 | "mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'), | |
693 | "dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'), | |
694 | "yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'), | |
695 | "dd-mm-yy" => ts('dd-mm-yyyy (31-12-2009)'), | |
696 | 'dd.mm.yy' => ts('dd.mm.yyyy (31.12.2009)'), | |
697 | "M d, yy" => ts('M d, yyyy (Dec 31, 2009)'), | |
698 | 'd M yy' => ts('d M yyyy (31 Dec 2009)'), | |
699 | "MM d, yy" => ts('MM d, yyyy (December 31, 2009)'), | |
700 | 'd MM yy' => ts('d MM yyyy (31 December 2009)'), | |
701 | "DD, d MM yy" => ts('DD, d MM yyyy (Thursday, 31 December 2009)'), | |
702 | "mm/dd" => ts('mm/dd (12/31)'), | |
703 | "dd-mm" => ts('dd-mm (31-12)'), | |
704 | "yy-mm" => ts('yyyy-mm (2009-12)'), | |
705 | 'M yy' => ts('M yyyy (Dec 2009)'), | |
706 | "yy" => ts('yyyy (2009)'), | |
707 | ); | |
708 | ||
709 | /* | |
e70a7fc0 TO |
710 | Year greater than 2000 get wrong result for following format |
711 | echo date( 'Y-m-d', strtotime( '7 Nov, 2001') ); | |
712 | echo date( 'Y-m-d', strtotime( '7 November, 2001') ); | |
713 | Return current year | |
714 | expected :: 2001-11-07 | |
715 | output :: 2009-11-07 | |
716 | However | |
717 | echo date( 'Y-m-d', strtotime( 'Nov 7, 2001') ); | |
718 | echo date( 'Y-m-d', strtotime( 'November 7, 2001') ); | |
719 | gives proper result | |
76e7a76c | 720 | */ |
6a488035 | 721 | |
6a488035 TO |
722 | return $dateInputFormats; |
723 | } | |
724 | ||
725 | /** | |
f9e31d7f | 726 | * Map date plugin and actual format that is used by PHP. |
76e7a76c CW |
727 | * |
728 | * @return array | |
6a488035 | 729 | */ |
00be9182 | 730 | public static function datePluginToPHPFormats() { |
6a488035 TO |
731 | $dateInputFormats = array( |
732 | "mm/dd/yy" => 'm/d/Y', | |
733 | "dd/mm/yy" => 'd/m/Y', | |
734 | "yy-mm-dd" => 'Y-m-d', | |
735 | "dd-mm-yy" => 'd-m-Y', | |
736 | "dd.mm.yy" => 'd.m.Y', | |
737 | "M d, yy" => 'M j, Y', | |
738 | "d M yy" => 'j M Y', | |
739 | "MM d, yy" => 'F j, Y', | |
740 | "d MM yy" => 'j F Y', | |
741 | "DD, d MM yy" => 'l, j F Y', | |
742 | "mm/dd" => 'm/d', | |
743 | "dd-mm" => 'd-m', | |
744 | "yy-mm" => 'Y-m', | |
745 | "M yy" => 'M Y', | |
746 | "yy" => 'Y', | |
747 | ); | |
748 | return $dateInputFormats; | |
749 | } | |
750 | ||
751 | /** | |
f9e31d7f | 752 | * Time formats. |
76e7a76c CW |
753 | * |
754 | * @return array | |
6a488035 | 755 | */ |
00be9182 | 756 | public static function getTimeFormats() { |
6795600d CW |
757 | return array( |
758 | '1' => ts('12 Hours'), | |
6a488035 TO |
759 | '2' => ts('24 Hours'), |
760 | ); | |
6a488035 TO |
761 | } |
762 | ||
763 | /** | |
f9e31d7f | 764 | * Get numeric options. |
79d7553f | 765 | * |
76e7a76c CW |
766 | * @param int $start |
767 | * @param int $end | |
6a488035 | 768 | * |
76e7a76c | 769 | * @return array |
6a488035 TO |
770 | */ |
771 | public static function getNumericOptions($start = 0, $end = 10) { | |
9fab6f51 | 772 | $numericOptions = array(); |
6a488035 | 773 | for ($i = $start; $i <= $end; $i++) { |
2aa397bc | 774 | $numericOptions[$i] = $i; |
6a488035 TO |
775 | } |
776 | return $numericOptions; | |
777 | } | |
f38395f7 KJ |
778 | |
779 | /** | |
f9e31d7f | 780 | * Barcode types. |
76e7a76c CW |
781 | * |
782 | * @return array | |
f38395f7 | 783 | */ |
00be9182 | 784 | public static function getBarcodeTypes() { |
c3831ebd EM |
785 | return array( |
786 | 'barcode' => ts('Linear (1D)'), | |
787 | 'qrcode' => ts('QR code'), | |
788 | ); | |
f38395f7 | 789 | } |
77d0b1f8 | 790 | |
791 | /** | |
f9e31d7f | 792 | * Dedupe rule types. |
76e7a76c CW |
793 | * |
794 | * @return array | |
77d0b1f8 | 795 | */ |
00be9182 | 796 | public static function getDedupeRuleTypes() { |
c3831ebd EM |
797 | return array( |
798 | 'Unsupervised' => ts('Unsupervised'), | |
799 | 'Supervised' => ts('Supervised'), | |
800 | 'General' => ts('General'), | |
801 | ); | |
77d0b1f8 | 802 | } |
f80ce889 | 803 | |
804 | /** | |
f9e31d7f | 805 | * Campaign group types. |
76e7a76c CW |
806 | * |
807 | * @return array | |
f80ce889 | 808 | */ |
00be9182 | 809 | public static function getCampaignGroupTypes() { |
c3831ebd EM |
810 | return array( |
811 | 'Include' => ts('Include'), | |
812 | 'Exclude' => ts('Exclude'), | |
813 | ); | |
f80ce889 | 814 | } |
815 | ||
816 | /** | |
f9e31d7f | 817 | * Subscription history method. |
76e7a76c CW |
818 | * |
819 | * @return array | |
f80ce889 | 820 | */ |
00be9182 | 821 | public static function getSubscriptionHistoryMethods() { |
c3831ebd EM |
822 | return array( |
823 | 'Admin' => ts('Admin'), | |
824 | 'Email' => ts('Email'), | |
825 | 'Web' => ts('Web'), | |
826 | 'API' => ts('API'), | |
827 | ); | |
f80ce889 | 828 | } |
829 | ||
830 | /** | |
f9e31d7f | 831 | * Premium units. |
76e7a76c CW |
832 | * |
833 | * @return array | |
f80ce889 | 834 | */ |
00be9182 | 835 | public static function getPremiumUnits() { |
c3831ebd EM |
836 | return array( |
837 | 'day' => ts('Day'), | |
838 | 'week' => ts('Week'), | |
839 | 'month' => ts('Month'), | |
840 | 'year' => ts('Year'), | |
841 | ); | |
f80ce889 | 842 | } |
56251ea7 | 843 | |
844 | /** | |
f9e31d7f | 845 | * Extension types. |
76e7a76c CW |
846 | * |
847 | * @return array | |
56251ea7 | 848 | */ |
00be9182 | 849 | public static function getExtensionTypes() { |
2aa397bc | 850 | return array( |
c3831ebd EM |
851 | 'payment' => ts('Payment'), |
852 | 'search' => ts('Search'), | |
853 | 'report' => ts('Report'), | |
854 | 'module' => ts('Module'), | |
855 | 'sms' => ts('SMS'), | |
856 | ); | |
56251ea7 | 857 | } |
858 | ||
859 | /** | |
f9e31d7f | 860 | * Job frequency. |
76e7a76c CW |
861 | * |
862 | * @return array | |
56251ea7 | 863 | */ |
00be9182 | 864 | public static function getJobFrequency() { |
c3831ebd EM |
865 | return array( |
866 | 'Daily' => ts('Daily'), | |
867 | 'Hourly' => ts('Hourly'), | |
868 | 'Always' => ts('Every time cron job is run'), | |
869 | ); | |
56251ea7 | 870 | } |
e204d358 | 871 | |
872 | /** | |
f9e31d7f | 873 | * Search builder operators. |
76e7a76c CW |
874 | * |
875 | * @return array | |
e204d358 | 876 | */ |
00be9182 | 877 | public static function getSearchBuilderOperators() { |
c3831ebd EM |
878 | return array( |
879 | '=' => '=', | |
880 | '!=' => '≠', | |
881 | '>' => '>', | |
882 | '<' => '<', | |
883 | '>=' => '≥', | |
884 | '<=' => '≤', | |
885 | 'IN' => ts('In'), | |
afa0b07c | 886 | 'NOT IN' => ts('Not In'), |
c3831ebd | 887 | 'LIKE' => ts('Like'), |
afa0b07c | 888 | 'NOT LIKE' => ts('Not Like'), |
c3831ebd EM |
889 | 'RLIKE' => ts('Regex'), |
890 | 'IS EMPTY' => ts('Is Empty'), | |
891 | 'IS NOT EMPTY' => ts('Not Empty'), | |
892 | 'IS NULL' => ts('Is Null'), | |
893 | 'IS NOT NULL' => ts('Not Null'), | |
894 | ); | |
e204d358 | 895 | } |
896 | ||
897 | /** | |
f9e31d7f | 898 | * Profile group types. |
e204d358 | 899 | * |
76e7a76c | 900 | * @return array |
e204d358 | 901 | */ |
00be9182 | 902 | public static function getProfileGroupType() { |
c3831ebd EM |
903 | $profileGroupType = array( |
904 | 'Activity' => ts('Activities'), | |
905 | 'Contribution' => ts('Contributions'), | |
906 | 'Membership' => ts('Memberships'), | |
907 | 'Participant' => ts('Participants'), | |
908 | ); | |
909 | $contactTypes = self::contactType(); | |
6795600d | 910 | $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); |
481a74f4 | 911 | $profileGroupType = array_merge($contactTypes, $profileGroupType); |
c3831ebd | 912 | |
e204d358 | 913 | return $profileGroupType; |
914 | } | |
915 | ||
916 | ||
917 | /** | |
f9e31d7f | 918 | * Word replacement match type. |
76e7a76c CW |
919 | * |
920 | * @return array | |
e204d358 | 921 | */ |
00be9182 | 922 | public static function getWordReplacementMatchType() { |
c3831ebd | 923 | return array( |
353ffa53 TO |
924 | 'exactMatch' => ts('Exact Match'), |
925 | 'wildcardMatch' => ts('Wildcard Match'), | |
926 | ); | |
e204d358 | 927 | } |
928 | ||
71a707c3 | 929 | /** |
f9e31d7f | 930 | * Mailing group types. |
76e7a76c CW |
931 | * |
932 | * @return array | |
71a707c3 | 933 | */ |
00be9182 | 934 | public static function getMailingGroupTypes() { |
c3831ebd EM |
935 | return array( |
936 | 'Include' => ts('Include'), | |
937 | 'Exclude' => ts('Exclude'), | |
938 | 'Base' => ts('Base'), | |
939 | ); | |
71a707c3 | 940 | } |
941 | ||
942 | /** | |
f9e31d7f | 943 | * Mailing Job Status. |
76e7a76c CW |
944 | * |
945 | * @return array | |
71a707c3 | 946 | */ |
00be9182 | 947 | public static function getMailingJobStatus() { |
c3831ebd EM |
948 | return array( |
949 | 'Scheduled' => ts('Scheduled'), | |
950 | 'Running' => ts('Running'), | |
951 | 'Complete' => ts('Complete'), | |
952 | 'Paused' => ts('Paused'), | |
953 | 'Canceled' => ts('Canceled'), | |
954 | ); | |
71a707c3 | 955 | } |
956 | ||
76e7a76c CW |
957 | /** |
958 | * @return array | |
959 | */ | |
00be9182 | 960 | public static function billingMode() { |
280f1b05 CW |
961 | return array( |
962 | CRM_Core_Payment::BILLING_MODE_FORM => 'form', | |
963 | CRM_Core_Payment::BILLING_MODE_BUTTON => 'button', | |
964 | CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', | |
965 | ); | |
966 | } | |
967 | ||
9775f926 | 968 | /** |
f9e31d7f | 969 | * Frequency unit for schedule reminders. |
76e7a76c CW |
970 | * |
971 | * @return array | |
9775f926 | 972 | */ |
00be9182 | 973 | public static function getScheduleReminderFrequencyUnits() { |
c3831ebd | 974 | //@todo update schema to refer to option group direct & remove this |
9775f926 | 975 | static $scheduleReminderFrequencyUnits = NULL; |
976 | if (!$scheduleReminderFrequencyUnits) { | |
977 | $scheduleReminderFrequencyUnits = array( | |
79d7553f | 978 | 'hour' => ts('hour'), |
979 | ) + CRM_Core_OptionGroup::values('recur_frequency_units'); | |
9775f926 | 980 | } |
981 | ||
982 | return $scheduleReminderFrequencyUnits; | |
983 | } | |
96025800 | 984 | |
6a488035 | 985 | } |