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