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