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