Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
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 | * | |
30 | * Stores all constants and pseudo constants for CRM application. | |
31 | * | |
32 | * examples of constants are "Contact Type" which will always be either | |
33 | * 'Individual', 'Household', 'Organization'. | |
34 | * | |
35 | * pseudo constants are entities from the database whose values rarely | |
36 | * change. examples are list of countries, states, location types, | |
37 | * relationship types. | |
38 | * | |
39 | * currently we're getting the data from the underlying database. this | |
40 | * will be reworked to use caching. | |
41 | * | |
42 | * Note: All pseudoconstants should be uninitialized or default to NULL. | |
43 | * This provides greater consistency/predictability after flushing. | |
44 | * | |
45 | * @package CRM | |
46 | * @copyright CiviCRM LLC (c) 2004-2013 | |
47 | * $Id$ | |
48 | * | |
49 | */ | |
50 | class CRM_Core_PseudoConstant { | |
51 | ||
52 | /** | |
53 | * location type | |
54 | * @var array | |
55 | * @static | |
56 | */ | |
57 | private static $locationType; | |
58 | ||
59 | /** | |
60 | * location vCard name | |
61 | * @var array | |
62 | * @static | |
63 | */ | |
64 | private static $locationVcardName; | |
65 | ||
66 | /** | |
67 | * location display name | |
68 | * @var array | |
69 | * @static | |
70 | */ | |
71 | private static $locationDisplayName; | |
72 | ||
73 | /** | |
74 | * activity type | |
75 | * @var array | |
76 | * @static | |
77 | */ | |
78 | private static $activityType; | |
79 | ||
80 | /** | |
81 | * payment processor billing modes | |
82 | * @var array | |
83 | * @static | |
84 | */ | |
85 | private static $billingMode; | |
86 | ||
87 | /** | |
88 | * component | |
89 | * @var array | |
90 | * @static | |
91 | */ | |
92 | private static $component; | |
93 | ||
94 | /** | |
95 | * individual prefix | |
96 | * @var array | |
97 | * @static | |
98 | */ | |
99 | private static $individualPrefix; | |
100 | ||
101 | /** | |
102 | * individual suffix | |
103 | * @var array | |
104 | * @static | |
105 | */ | |
106 | private static $individualSuffix; | |
107 | ||
108 | /** | |
109 | * gender | |
110 | * @var array | |
111 | * @static | |
112 | */ | |
113 | private static $gender; | |
114 | ||
115 | /** | |
116 | * im protocols | |
117 | * @var array | |
118 | * @static | |
119 | */ | |
120 | private static $imProvider; | |
121 | ||
122 | /** | |
123 | * website protocols | |
124 | * @var array | |
125 | * @static | |
126 | */ | |
127 | private static $websiteType; | |
128 | ||
129 | /** | |
130 | * im protocols | |
131 | * @var array | |
132 | * @static | |
133 | */ | |
134 | private static $fromEmailAddress; | |
135 | ||
136 | /** | |
137 | * states, provinces | |
138 | * @var array | |
139 | * @static | |
140 | */ | |
141 | private static $stateProvince; | |
142 | ||
143 | /** | |
144 | * counties | |
145 | * @var array | |
146 | * @static | |
147 | */ | |
148 | private static $county; | |
149 | ||
150 | /** | |
151 | * states/provinces abbreviations | |
152 | * @var array | |
153 | * @static | |
154 | */ | |
155 | private static $stateProvinceAbbreviation; | |
156 | ||
157 | /** | |
158 | * country | |
159 | * @var array | |
160 | * @static | |
161 | */ | |
162 | private static $country; | |
163 | ||
164 | /** | |
165 | * countryIsoCode | |
166 | * @var array | |
167 | * @static | |
168 | */ | |
169 | private static $countryIsoCode; | |
170 | ||
171 | /** | |
172 | * tag | |
173 | * @var array | |
174 | * @static | |
175 | */ | |
176 | private static $tag; | |
177 | ||
178 | /** | |
179 | * group | |
180 | * @var array | |
181 | * @static | |
182 | */ | |
183 | private static $group; | |
184 | ||
185 | /** | |
186 | * groupIterator | |
187 | * @var mixed | |
188 | * @static | |
189 | */ | |
190 | private static $groupIterator; | |
191 | ||
192 | /** | |
193 | * relationshipType | |
194 | * @var array | |
195 | * @static | |
196 | */ | |
197 | private static $relationshipType; | |
198 | ||
199 | /** | |
200 | * civicrm groups that are not smart groups | |
201 | * @var array | |
202 | * @static | |
203 | */ | |
204 | private static $staticGroup; | |
205 | ||
206 | /** | |
207 | * user framework groups | |
208 | * @var array | |
209 | * @static | |
210 | */ | |
211 | private static $ufGroup; | |
212 | ||
213 | /** | |
214 | * custom groups | |
215 | * @var array | |
216 | * @static | |
217 | */ | |
218 | private static $customGroup; | |
219 | ||
220 | /** | |
221 | * currency codes | |
222 | * @var array | |
223 | * @static | |
224 | */ | |
225 | private static $currencyCode; | |
226 | ||
227 | /** | |
228 | * currency Symbols | |
229 | * @var array | |
230 | * @static | |
231 | */ | |
232 | private static $currencySymbols; | |
233 | ||
234 | /** | |
235 | * project tasks | |
236 | * @var array | |
237 | * @static | |
238 | */ | |
239 | private static $tasks; | |
240 | ||
241 | /** | |
242 | * preferred communication methods | |
243 | * @var array | |
244 | * @static | |
245 | */ | |
246 | private static $pcm; | |
247 | ||
248 | /** | |
249 | * payment processor | |
250 | * @var array | |
251 | * @static | |
252 | */ | |
253 | private static $paymentProcessor; | |
254 | ||
255 | /** | |
256 | * payment processor types | |
257 | * @var array | |
258 | * @static | |
259 | */ | |
260 | private static $paymentProcessorType; | |
261 | ||
262 | /** | |
263 | * World Region | |
264 | * @var array | |
265 | * @static | |
266 | */ | |
267 | private static $worldRegions; | |
268 | ||
269 | /** | |
270 | * honorType | |
271 | * @var array | |
272 | * @static | |
273 | */ | |
274 | private static $honorType; | |
275 | ||
276 | /** | |
277 | * activity status | |
278 | * @var array | |
279 | * @static | |
280 | */ | |
281 | private static $activityStatus; | |
282 | ||
283 | /** | |
284 | * priority | |
285 | * @var array | |
286 | * @static | |
287 | */ | |
288 | private static $priority; | |
289 | ||
290 | /** | |
291 | * wysiwyg Editor | |
292 | * @var array | |
293 | * @static | |
294 | */ | |
295 | private static $wysiwygEditor; | |
296 | ||
297 | /** | |
298 | * Mapping Types | |
299 | * @var array | |
300 | * @static | |
301 | */ | |
302 | private static $mappingType; | |
303 | ||
304 | /** | |
305 | * Phone Types | |
306 | * @var array | |
307 | * @static | |
308 | */ | |
309 | private static $phoneType; | |
310 | ||
311 | /** | |
312 | * Visibility | |
313 | * @var array | |
314 | * @static | |
315 | */ | |
316 | private static $visibility; | |
317 | ||
318 | /** | |
319 | * Mail Protocols | |
320 | * @var array | |
321 | * @static | |
322 | */ | |
323 | private static $mailProtocol; | |
324 | ||
325 | /** | |
326 | * Greetings | |
327 | * @var array | |
328 | * @static | |
329 | */ | |
330 | private static $greeting; | |
331 | ||
332 | /** | |
333 | * Default Greetings | |
334 | * @var array | |
335 | * @static | |
336 | */ | |
337 | private static $greetingDefaults; | |
338 | ||
339 | /** | |
340 | * Extensions of type module | |
341 | * @var array | |
342 | * @static | |
343 | */ | |
344 | private static $extensions; | |
345 | ||
346 | /** | |
347 | * activity contacts | |
348 | * @var array | |
349 | * @static | |
350 | */ | |
351 | private static $activityContacts; | |
352 | ||
353 | /** | |
354 | * event contacts | |
355 | * @var array | |
356 | * @static | |
357 | */ | |
358 | private static $eventContacts; | |
359 | ||
360 | /** | |
361 | * auto renew options | |
362 | * @var array | |
363 | * @static | |
364 | */ | |
365 | private static $autoRenew; | |
366 | ||
367 | /** | |
368 | * batch mode options | |
369 | * @var array | |
370 | * @static | |
371 | */ | |
372 | private static $batchModes; | |
373 | ||
374 | /** | |
375 | * batch type options | |
376 | * @var array | |
377 | * @static | |
378 | */ | |
379 | private static $batchTypes; | |
380 | ||
381 | /** | |
382 | * batch status options | |
383 | * @var array | |
384 | * @static | |
385 | */ | |
386 | private static $batchStatues; | |
387 | ||
388 | /** | |
389 | * contact Type | |
390 | * @var array | |
391 | * @static | |
392 | */ | |
393 | private static $contactType; | |
394 | ||
395 | /** | |
396 | * Financial Account Type | |
397 | * @var array | |
398 | * @static | |
399 | */ | |
400 | private static $accountOptionValues; | |
401 | ||
402 | /** | |
403 | * populate the object from the database. generic populate | |
404 | * method | |
405 | * | |
406 | * The static array $var is populated from the db | |
407 | * using the <b>$name DAO</b>. | |
408 | * | |
409 | * Note: any database errors will be trapped by the DAO. | |
410 | * | |
411 | * @param array $var the associative array we will fill | |
412 | * @param string $name the name of the DAO | |
413 | * @param boolean $all get all objects. default is to get only active ones. | |
414 | * @param string $retrieve the field that we are interested in (normally name, differs in some objects) | |
415 | * @param string $filter the field that we want to filter the result set with | |
416 | * @param string $condition the condition that gets passed to the final query as the WHERE clause | |
417 | * | |
418 | * @return void | |
419 | * @access public | |
420 | * @static | |
421 | */ | |
8360b701 DL |
422 | public static function populate( |
423 | &$var, | |
424 | $name, | |
425 | $all = FALSE, | |
426 | $retrieve = 'name', | |
427 | $filter = 'is_active', | |
428 | $condition = NULL, | |
429 | $orderby = NULL, | |
430 | $key = 'id', | |
431 | $force = NULL | |
432 | ) { | |
6a488035 TO |
433 | $cacheKey = "CRM_PC_{$name}_{$all}_{$key}_{$retrieve}_{$filter}_{$condition}_{$orderby}"; |
434 | $cache = CRM_Utils_Cache::singleton(); | |
435 | $var = $cache->get($cacheKey); | |
436 | if ($var && empty($force)) { | |
437 | return $var; | |
438 | } | |
439 | ||
440 | $object = new $name ( ); | |
441 | ||
442 | $object->selectAdd(); | |
443 | $object->selectAdd("$key, $retrieve"); | |
444 | if ($condition) { | |
445 | $object->whereAdd($condition); | |
446 | } | |
447 | ||
448 | if (!$orderby) { | |
449 | $object->orderBy($retrieve); | |
450 | } | |
451 | else { | |
452 | $object->orderBy($orderby); | |
453 | } | |
454 | ||
455 | if (!$all) { | |
456 | $object->$filter = 1; | |
457 | } | |
458 | ||
459 | $object->find(); | |
460 | $var = array(); | |
461 | while ($object->fetch()) { | |
462 | $var[$object->$key] = $object->$retrieve; | |
463 | } | |
464 | ||
465 | $cache->set($cacheKey, $var); | |
466 | } | |
467 | ||
468 | /** | |
469 | * Flush given pseudoconstant so it can be reread from db | |
470 | * nex time it's requested. | |
471 | * | |
472 | * @access public | |
473 | * @static | |
474 | * | |
475 | * @param boolean $name pseudoconstant to be flushed | |
476 | * | |
477 | */ | |
478 | public static function flush($name) { | |
fa56270d CW |
479 | if (isset(self::$$name)) { |
480 | self::$$name = NULL; | |
481 | } | |
6a488035 TO |
482 | } |
483 | ||
484 | /** | |
485 | * Get all location types. | |
486 | * | |
487 | * The static array locationType is returned | |
488 | * | |
489 | * @access public | |
490 | * @static | |
491 | * | |
492 | * @param boolean $all - get All location types - default is to get only active ones. | |
493 | * | |
494 | * @return array - array reference of all location types. | |
495 | * | |
496 | */ | |
497 | public static function &locationType($all = FALSE) { | |
498 | if (!self::$locationType) { | |
499 | self::populate(self::$locationType, 'CRM_Core_DAO_LocationType', $all); | |
500 | } | |
501 | return self::$locationType; | |
502 | } | |
503 | ||
504 | /** | |
505 | * Get all location vCard names. | |
506 | * | |
507 | * The static array locationVcardName is returned | |
508 | * | |
509 | * @access public | |
510 | * @static | |
511 | * | |
512 | * @param boolean $all - get All location vCard names - default is to get only active ones. | |
513 | * | |
514 | * @return array - array reference of all location vCard names. | |
515 | * | |
516 | */ | |
517 | public static function &locationVcardName($all = FALSE) { | |
518 | if (!self::$locationVcardName) { | |
519 | self::populate(self::$locationVcardName, 'CRM_Core_DAO_LocationType', $all, 'vcard_name'); | |
520 | } | |
521 | return self::$locationVcardName; | |
522 | } | |
523 | ||
524 | /** | |
525 | * Get all location Display names. | |
526 | * | |
527 | * The static array locationDisplayName is returned | |
528 | * | |
529 | * @access public | |
530 | * @static | |
531 | * | |
532 | * @param boolean $all - get All location display names - default is to get only active ones. | |
533 | * | |
534 | * @return array - array reference of all location display names. | |
535 | * | |
536 | */ | |
537 | public static function &locationDisplayName($all = FALSE) { | |
538 | if (!self::$locationDisplayName) { | |
539 | self::populate(self::$locationDisplayName, 'CRM_Core_DAO_LocationType', $all, 'display_name'); | |
540 | } | |
541 | return self::$locationDisplayName; | |
542 | } | |
543 | ||
544 | /** | |
545 | * Get all Activty types. | |
546 | * | |
547 | * The static array activityType is returned | |
548 | * | |
549 | * @param boolean $all - get All Activity types - default is to get only active ones. | |
550 | * | |
551 | * @access public | |
552 | * @static | |
553 | * | |
554 | * @return array - array reference of all activity types. | |
555 | */ | |
556 | public static function &activityType() { | |
557 | $args = func_get_args(); | |
558 | $all = CRM_Utils_Array::value(0, $args, TRUE); | |
559 | $includeCaseActivities = CRM_Utils_Array::value(1, $args, FALSE); | |
560 | $reset = CRM_Utils_Array::value(2, $args, FALSE); | |
561 | $returnColumn = CRM_Utils_Array::value(3, $args, 'label'); | |
562 | $includeCampaignActivities = CRM_Utils_Array::value(4, $args, FALSE); | |
563 | $onlyComponentActivities = CRM_Utils_Array::value(5, $args, FALSE); | |
564 | $index = (int) $all . '_' . $returnColumn . '_' . (int) $includeCaseActivities; | |
565 | $index .= '_' . (int) $includeCampaignActivities; | |
566 | $index .= '_' . (int) $onlyComponentActivities; | |
567 | ||
568 | if (NULL === self::$activityType) { | |
569 | self::$activityType = array(); | |
570 | } | |
571 | ||
572 | if (!isset(self::$activityType[$index]) || $reset) { | |
573 | $condition = NULL; | |
574 | if (!$all) { | |
575 | $condition = 'AND filter = 0'; | |
576 | } | |
577 | $componentClause = " v.component_id IS NULL"; | |
578 | if ($onlyComponentActivities) { | |
579 | $componentClause = " v.component_id IS NOT NULL"; | |
580 | } | |
581 | ||
582 | $componentIds = array(); | |
583 | $compInfo = CRM_Core_Component::getEnabledComponents(); | |
584 | ||
585 | // build filter for listing activity types only if their | |
586 | // respective components are enabled | |
587 | foreach ($compInfo as $compName => $compObj) { | |
588 | if ($compName == 'CiviCase') { | |
589 | if ($includeCaseActivities) { | |
590 | $componentIds[] = $compObj->componentID; | |
591 | } | |
592 | } | |
593 | elseif ($compName == 'CiviCampaign') { | |
594 | if ($includeCampaignActivities) { | |
595 | $componentIds[] = $compObj->componentID; | |
596 | } | |
597 | } | |
598 | else { | |
599 | $componentIds[] = $compObj->componentID; | |
600 | } | |
601 | } | |
602 | ||
603 | if (count($componentIds)) { | |
604 | $componentIds = implode(',', $componentIds); | |
605 | $componentClause = " ($componentClause OR v.component_id IN ($componentIds))"; | |
606 | if ($onlyComponentActivities) { | |
607 | $componentClause = " ( v.component_id IN ($componentIds ) )"; | |
608 | } | |
609 | } | |
610 | $condition = $condition . ' AND ' . $componentClause; | |
611 | ||
612 | self::$activityType[$index] = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, $condition, $returnColumn); | |
613 | } | |
614 | return self::$activityType[$index]; | |
615 | } | |
616 | ||
617 | /** | |
618 | * Get all payment-processor billing modes | |
619 | * | |
620 | * @access public | |
621 | * @static | |
622 | * | |
623 | * @return array ($id => $name) | |
624 | */ | |
625 | public static function billingMode() { | |
626 | if (!self::$billingMode) { | |
627 | self::$billingMode = array( | |
628 | CRM_Core_Payment::BILLING_MODE_FORM => 'form', | |
629 | CRM_Core_Payment::BILLING_MODE_BUTTON => 'button', | |
630 | CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', | |
631 | ); | |
632 | } | |
633 | return self::$billingMode; | |
634 | } | |
635 | ||
636 | /** | |
637 | * Get all component names | |
638 | * | |
639 | * @access public | |
640 | * @static | |
641 | * | |
642 | * @return array - array reference of all location display names. | |
643 | * | |
644 | */ | |
645 | public static function &component() { | |
646 | if (!self::$component) { | |
647 | self::populate(self::$component, 'CRM_Core_DAO_Component', TRUE, 'name'); | |
648 | } | |
649 | return self::$component; | |
650 | } | |
651 | ||
652 | ||
653 | /** | |
654 | * Get all Individual Prefix. | |
655 | * | |
656 | * The static array individualPrefix is returned | |
657 | * | |
658 | * @access public | |
659 | * @static | |
660 | * | |
661 | * @param boolean $all - get All Individual Prefix - default is to get only active ones. | |
662 | * | |
663 | * @return array - array reference of all individual prefix. | |
664 | * | |
665 | */ | |
666 | public static function &individualPrefix() { | |
667 | if (!self::$individualPrefix) { | |
668 | self::$individualPrefix = CRM_Core_OptionGroup::values('individual_prefix'); | |
669 | } | |
670 | return self::$individualPrefix; | |
671 | } | |
672 | ||
673 | /** | |
674 | * Get all phone type | |
675 | * The static array phoneType is returned | |
676 | * | |
677 | * @access public | |
678 | * @static | |
679 | * | |
680 | * @param boolean $all - get All phone type - default is to get | |
681 | * only active ones. | |
682 | * | |
683 | * @return array - array reference of all phone types. | |
684 | * | |
685 | */ | |
686 | public static function &phoneType() { | |
687 | if (!self::$phoneType) { | |
688 | self::$phoneType = CRM_Core_OptionGroup::values('phone_type'); | |
689 | } | |
690 | return self::$phoneType; | |
691 | } | |
692 | ||
693 | /** | |
694 | * Get all Individual Suffix. | |
695 | * | |
696 | * The static array individualSuffix is returned | |
697 | * | |
698 | * @access public | |
699 | * @static | |
700 | * | |
701 | * @param boolean $all - get All Individual Suffix - default is to get only active ones. | |
702 | * | |
703 | * @return array - array reference of all individual suffix. | |
704 | * | |
705 | */ | |
706 | public static function &individualSuffix() { | |
707 | if (!self::$individualSuffix) { | |
708 | self::$individualSuffix = CRM_Core_OptionGroup::values('individual_suffix'); | |
709 | } | |
710 | return self::$individualSuffix; | |
711 | } | |
712 | ||
713 | /** | |
714 | * Get all Gender. | |
715 | * | |
716 | * The static array gender is returned | |
717 | * | |
718 | * @access public | |
719 | * @static | |
720 | * | |
721 | * @param boolean $all - get All Gender - default is to get only active ones. | |
722 | * | |
723 | * @return array - array reference of all gender. | |
724 | * | |
725 | */ | |
726 | public static function &gender($localize = FALSE) { | |
727 | if (!self::$gender) { | |
728 | self::$gender = CRM_Core_OptionGroup::values('gender', FALSE, FALSE, $localize); | |
729 | } | |
730 | return self::$gender; | |
731 | } | |
732 | ||
733 | /** | |
734 | * Get all the IM Providers from database. | |
735 | * | |
736 | * The static array imProvider is returned, and if it's | |
737 | * called the first time, the <b>IM DAO</b> is used | |
738 | * to get all the IM Providers. | |
739 | * | |
740 | * Note: any database errors will be trapped by the DAO. | |
741 | * | |
742 | * @access public | |
743 | * @static | |
744 | * | |
745 | * @return array - array reference of all IM providers. | |
746 | * | |
747 | */ | |
748 | public static function &IMProvider($localize = FALSE) { | |
749 | if (!self::$imProvider) { | |
750 | self::$imProvider = CRM_Core_OptionGroup::values('instant_messenger_service', FALSE, FALSE, $localize); | |
751 | } | |
752 | return self::$imProvider; | |
753 | } | |
754 | ||
755 | /** | |
756 | * Get all the website types from database. | |
757 | * | |
758 | * The static array websiteType is returned, and if it's | |
759 | * called the first time, the <b>Website DAO</b> is used | |
760 | * to get all the Website Types. | |
761 | * | |
762 | * Note: any database errors will be trapped by the DAO. | |
763 | * | |
764 | * @access public | |
765 | * @static | |
766 | * | |
767 | * @return array - array reference of all Website types. | |
768 | * | |
769 | */ | |
770 | public static function &websiteType() { | |
771 | if (!self::$websiteType) { | |
772 | self::$websiteType = CRM_Core_OptionGroup::values('website_type'); | |
773 | } | |
774 | return self::$websiteType; | |
775 | } | |
776 | ||
777 | /** | |
778 | * Get the all From Email Address from database. | |
779 | * | |
780 | * The static array $fromEmailAddress is returned, and if it's | |
781 | * called the first time, DAO is used | |
782 | * to get all the From Email Address | |
783 | * | |
784 | * Note: any database errors will be trapped by the DAO. | |
785 | * | |
786 | * @access public | |
787 | * @static | |
788 | * | |
789 | * @return array - array reference of all From Email Address. | |
790 | */ | |
791 | public static function &fromEmailAddress() { | |
792 | if (!self::$fromEmailAddress) { | |
793 | self::$fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address'); | |
794 | } | |
795 | return self::$fromEmailAddress; | |
796 | } | |
797 | ||
798 | /** | |
799 | * Get the all Mail Protocols from database. | |
800 | * | |
801 | * The static array mailProtocol is returned, and if it's | |
802 | * called the first time, the DAO is used | |
803 | * to get all the Mail Protocol. | |
804 | * | |
805 | * Note: any database errors will be trapped by the DAO. | |
806 | * | |
807 | * @access public | |
808 | * @static | |
809 | * | |
810 | * @return array - array reference of all Mail Protocols. | |
811 | */ | |
812 | public static function &mailProtocol() { | |
813 | if (!self::$mailProtocol) { | |
814 | self::$mailProtocol = CRM_Core_OptionGroup::values('mail_protocol'); | |
815 | } | |
816 | return self::$mailProtocol; | |
817 | } | |
818 | ||
819 | /** | |
820 | * Get all the State/Province from database. | |
821 | * | |
822 | * The static array stateProvince is returned, and if it's | |
823 | * called the first time, the <b>State Province DAO</b> is used | |
824 | * to get all the States. | |
825 | * | |
826 | * Note: any database errors will be trapped by the DAO. | |
827 | * | |
828 | * @access public | |
829 | * @static | |
830 | * | |
831 | * @param int $id - Optional id to return | |
832 | * | |
833 | * @return array - array reference of all State/Provinces. | |
834 | * | |
835 | */ | |
836 | public static function &stateProvince($id = FALSE, $limit = TRUE) { | |
837 | if (($id && !CRM_Utils_Array::value($id, self::$stateProvince)) || !self::$stateProvince || !$id) { | |
838 | $whereClause = FALSE; | |
839 | $config = CRM_Core_Config::singleton(); | |
840 | if ($limit) { | |
841 | $countryIsoCodes = self::countryIsoCode(); | |
842 | $limitCodes = $config->provinceLimit(); | |
843 | $limitIds = array(); | |
844 | foreach ($limitCodes as $code) { | |
845 | $limitIds = array_merge($limitIds, array_keys($countryIsoCodes, $code)); | |
846 | } | |
847 | if (!empty($limitIds)) { | |
848 | $whereClause = 'country_id IN (' . implode(', ', $limitIds) . ')'; | |
849 | } | |
850 | else { | |
851 | $whereClause = FALSE; | |
852 | } | |
853 | } | |
854 | self::populate(self::$stateProvince, 'CRM_Core_DAO_StateProvince', TRUE, 'name', 'is_active', $whereClause); | |
855 | ||
856 | // localise the province names if in an non-en_US locale | |
857 | global $tsLocale; | |
858 | if ($tsLocale != '' and $tsLocale != 'en_US') { | |
859 | $i18n = CRM_Core_I18n::singleton(); | |
860 | $i18n->localizeArray(self::$stateProvince, array( | |
861 | 'context' => 'province', | |
862 | )); | |
863 | self::$stateProvince = CRM_Utils_Array::asort(self::$stateProvince); | |
864 | } | |
865 | } | |
866 | if ($id) { | |
867 | if (array_key_exists($id, self::$stateProvince)) { | |
868 | return self::$stateProvince[$id]; | |
869 | } | |
870 | else { | |
871 | $result = NULL; | |
872 | return $result; | |
873 | } | |
874 | } | |
875 | return self::$stateProvince; | |
876 | } | |
877 | ||
878 | /** | |
879 | * Get all the State/Province abbreviations from the database. | |
880 | * | |
881 | * Same as above, except gets the abbreviations instead of the names. | |
882 | * | |
883 | * @access public | |
884 | * @static | |
885 | * | |
886 | * @param int $id - Optional id to return | |
887 | * | |
888 | * @return array - array reference of all State/Province abbreviations. | |
889 | */ | |
890 | public static function &stateProvinceAbbreviation($id = FALSE, $limit = TRUE) { | |
891 | if ($id > 1) { | |
892 | $query = " | |
893 | SELECT abbreviation | |
894 | FROM civicrm_state_province | |
895 | WHERE id = %1"; | |
896 | $params = array( | |
897 | 1 => array( | |
898 | $id, | |
899 | 'Integer', | |
900 | ), | |
901 | ); | |
902 | return CRM_Core_DAO::singleValueQuery($query, $params); | |
903 | } | |
904 | ||
905 | if (!self::$stateProvinceAbbreviation || !$id) { | |
906 | ||
907 | $whereClause = FALSE; | |
908 | ||
909 | if ($limit) { | |
910 | $config = CRM_Core_Config::singleton(); | |
911 | $countryIsoCodes = self::countryIsoCode(); | |
912 | $limitCodes = $config->provinceLimit(); | |
913 | $limitIds = array(); | |
914 | foreach ($limitCodes as $code) { | |
915 | $tmpArray = array_keys($countryIsoCodes, $code); | |
916 | ||
917 | if (!empty($tmpArray)) { | |
918 | $limitIds[] = array_shift($tmpArray); | |
919 | } | |
920 | } | |
921 | if (!empty($limitIds)) { | |
922 | $whereClause = 'country_id IN (' . implode(', ', $limitIds) . ')'; | |
923 | } | |
924 | } | |
925 | self::populate(self::$stateProvinceAbbreviation, 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', $whereClause); | |
926 | } | |
927 | ||
928 | if ($id) { | |
929 | if (array_key_exists($id, self::$stateProvinceAbbreviation)) { | |
930 | return self::$stateProvinceAbbreviation[$id]; | |
931 | } | |
932 | else { | |
933 | $result = NULL; | |
934 | return $result; | |
935 | } | |
936 | } | |
937 | return self::$stateProvinceAbbreviation; | |
938 | } | |
939 | ||
940 | /** | |
941 | * Get all the countries from database. | |
942 | * | |
943 | * The static array country is returned, and if it's | |
944 | * called the first time, the <b>Country DAO</b> is used | |
945 | * to get all the countries. | |
946 | * | |
947 | * Note: any database errors will be trapped by the DAO. | |
948 | * | |
949 | * @access public | |
950 | * @static | |
951 | * | |
952 | * @param int $id - Optional id to return | |
953 | * | |
954 | * @return array - array reference of all countries. | |
955 | * | |
956 | */ | |
957 | public static function country($id = FALSE, $applyLimit = TRUE) { | |
958 | if (($id && !CRM_Utils_Array::value($id, self::$country)) || !self::$country || !$id) { | |
959 | ||
960 | $config = CRM_Core_Config::singleton(); | |
961 | $limitCodes = array(); | |
962 | ||
963 | if ($applyLimit) { | |
964 | // limit the country list to the countries specified in CIVICRM_COUNTRY_LIMIT | |
965 | // (ensuring it's a subset of the legal values) | |
966 | // K/P: We need to fix this, i dont think it works with new setting files | |
967 | $limitCodes = $config->countryLimit(); | |
968 | if (!is_array($limitCodes)) { | |
969 | $limitCodes = array( | |
970 | $config->countryLimit => 1, | |
971 | ); | |
972 | } | |
973 | ||
974 | $limitCodes = array_intersect(self::countryIsoCode(), $limitCodes); | |
975 | } | |
976 | ||
977 | if (count($limitCodes)) { | |
978 | $whereClause = "iso_code IN ('" . implode("', '", $limitCodes) . "')"; | |
979 | } | |
980 | else { | |
981 | $whereClause = NULL; | |
982 | } | |
983 | ||
984 | self::populate(self::$country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active', $whereClause); | |
985 | ||
986 | // if default country is set, percolate it to the top | |
987 | if ($config->defaultContactCountry()) { | |
988 | $countryIsoCodes = self::countryIsoCode(); | |
989 | $defaultID = array_search($config->defaultContactCountry(), $countryIsoCodes); | |
990 | if ($defaultID !== FALSE) { | |
991 | $default[$defaultID] = CRM_Utils_Array::value($defaultID, self::$country); | |
992 | self::$country = $default + self::$country; | |
993 | } | |
994 | } | |
995 | ||
996 | // localise the country names if in an non-en_US locale | |
997 | global $tsLocale; | |
998 | if ($tsLocale != '' and $tsLocale != 'en_US') { | |
999 | $i18n = CRM_Core_I18n::singleton(); | |
1000 | $i18n->localizeArray(self::$country, array( | |
1001 | 'context' => 'country', | |
1002 | )); | |
1003 | self::$country = CRM_Utils_Array::asort(self::$country); | |
1004 | } | |
1005 | } | |
1006 | if ($id) { | |
1007 | if (array_key_exists($id, self::$country)) { | |
1008 | return self::$country[$id]; | |
1009 | } | |
1010 | else { | |
1011 | return NULL; | |
1012 | } | |
1013 | } | |
1014 | return self::$country; | |
1015 | } | |
1016 | ||
1017 | /** | |
1018 | * Get all the country ISO Code abbreviations from the database. | |
1019 | * | |
1020 | * The static array countryIsoCode is returned, and if it's | |
1021 | * called the first time, the <b>Country DAO</b> is used | |
1022 | * to get all the countries' ISO codes. | |
1023 | * | |
1024 | * Note: any database errors will be trapped by the DAO. | |
1025 | * | |
1026 | * @access public | |
1027 | * @static | |
1028 | * | |
1029 | * @return array - array reference of all country ISO codes. | |
1030 | * | |
1031 | */ | |
1032 | public static function &countryIsoCode($id = FALSE) { | |
1033 | if (!self::$countryIsoCode) { | |
1034 | self::populate(self::$countryIsoCode, 'CRM_Core_DAO_Country', TRUE, 'iso_code'); | |
1035 | } | |
1036 | if ($id) { | |
1037 | if (array_key_exists($id, self::$countryIsoCode)) { | |
1038 | return self::$countryIsoCode[$id]; | |
1039 | } | |
1040 | else { | |
1041 | return NULL; | |
1042 | } | |
1043 | } | |
1044 | return self::$countryIsoCode; | |
1045 | } | |
1046 | ||
1047 | /** | |
1048 | * Get all the categories from database. | |
1049 | * | |
1050 | * The static array tag is returned, and if it's | |
1051 | * called the first time, the <b>Tag DAO</b> is used | |
1052 | * to get all the categories. | |
1053 | * | |
1054 | * Note: any database errors will be trapped by the DAO. | |
1055 | * | |
1056 | * @access public | |
1057 | * @static | |
1058 | * | |
1059 | * @return array - array reference of all categories. | |
1060 | * | |
1061 | */ | |
1062 | public static function &tag() { | |
1063 | if (!self::$tag) { | |
1064 | self::populate(self::$tag, 'CRM_Core_DAO_Tag', TRUE); | |
1065 | } | |
1066 | return self::$tag; | |
1067 | } | |
1068 | ||
1069 | /** | |
1070 | * Get all groups from database | |
1071 | * | |
1072 | * The static array group is returned, and if it's | |
1073 | * called the first time, the <b>Group DAO</b> is used | |
1074 | * to get all the groups. | |
1075 | * | |
1076 | * Note: any database errors will be trapped by the DAO. | |
1077 | * | |
1078 | * @param string $groupType type of group(Access/Mailing) | |
1079 | * @param boolen $excludeHidden exclude hidden groups. | |
1080 | * | |
1081 | * @access public | |
1082 | * @static | |
1083 | * | |
1084 | * @return array - array reference of all groups. | |
1085 | * | |
1086 | */ | |
1087 | public static function &allGroup($groupType = NULL, $excludeHidden = TRUE) { | |
1088 | $condition = CRM_Contact_BAO_Group::groupTypeCondition($groupType, $excludeHidden); | |
1089 | ||
1090 | if (!self::$group) { | |
1091 | self::$group = array(); | |
1092 | } | |
1093 | ||
1094 | $groupKey = $groupType ? $groupType : 'null'; | |
1095 | ||
1096 | if (!isset(self::$group[$groupKey])) { | |
1097 | self::$group[$groupKey] = NULL; | |
1098 | self::populate(self::$group[$groupKey], 'CRM_Contact_DAO_Group', FALSE, 'title', 'is_active', $condition); | |
1099 | } | |
1100 | return self::$group[$groupKey]; | |
1101 | } | |
1102 | ||
1103 | /** | |
1104 | * Create or get groups iterator (iterates over nested groups in a | |
1105 | * logical fashion) | |
1106 | * | |
1107 | * The GroupNesting instance is returned; it's created if this is being | |
1108 | * called for the first time | |
1109 | * | |
1110 | * | |
1111 | * @access public | |
1112 | * @static | |
1113 | * | |
1114 | * @return mixed - instance of CRM_Contact_BAO_GroupNesting | |
1115 | * | |
1116 | */ | |
1117 | public static function &groupIterator($styledLabels = FALSE) { | |
1118 | if (!self::$groupIterator) { | |
1119 | /* | |
8360b701 DL |
1120 | When used as an object, GroupNesting implements Iterator |
1121 | and iterates nested groups in a logical manner for us | |
1122 | */ | |
6a488035 TO |
1123 | self::$groupIterator = new CRM_Contact_BAO_GroupNesting($styledLabels); |
1124 | } | |
1125 | return self::$groupIterator; | |
1126 | } | |
1127 | ||
1128 | /** | |
1129 | * Get all permissioned groups from database | |
1130 | * | |
1131 | * The static array group is returned, and if it's | |
1132 | * called the first time, the <b>Group DAO</b> is used | |
1133 | * to get all the groups. | |
1134 | * | |
1135 | * Note: any database errors will be trapped by the DAO. | |
1136 | * | |
1137 | * @param string $groupType type of group(Access/Mailing) | |
1138 | * @param boolen $excludeHidden exclude hidden groups. | |
1139 | ||
1140 | * @access public | |
1141 | * @static | |
1142 | * | |
1143 | * @return array - array reference of all groups. | |
1144 | * | |
1145 | */ | |
1146 | public static function group($groupType = NULL, $excludeHidden = TRUE) { | |
1147 | return CRM_Core_Permission::group($groupType, $excludeHidden); | |
1148 | } | |
1149 | ||
1150 | /** | |
1151 | * Get all permissioned groups from database | |
1152 | * | |
1153 | * The static array group is returned, and if it's | |
1154 | * called the first time, the <b>Group DAO</b> is used | |
1155 | * to get all the groups. | |
1156 | * | |
1157 | * Note: any database errors will be trapped by the DAO. | |
1158 | * | |
1159 | * @access public | |
1160 | * @static | |
1161 | * | |
1162 | * @return array - array reference of all groups. | |
1163 | * | |
1164 | */ | |
1165 | public static function &staticGroup($onlyPublic = FALSE, $groupType = NULL, $excludeHidden = TRUE) { | |
1166 | if (!self::$staticGroup) { | |
1167 | $condition = 'saved_search_id = 0 OR saved_search_id IS NULL'; | |
1168 | if ($onlyPublic) { | |
1169 | $condition .= " AND visibility != 'User and User Admin Only'"; | |
1170 | } | |
1171 | ||
1172 | if ($groupType) { | |
1173 | $condition .= ' AND ' . CRM_Contact_BAO_Group::groupTypeCondition($groupType); | |
1174 | } | |
1175 | ||
1176 | if ($excludeHidden) { | |
1177 | $condition .= ' AND is_hidden != 1 '; | |
1178 | } | |
1179 | ||
1180 | self::populate(self::$staticGroup, 'CRM_Contact_DAO_Group', FALSE, 'title', 'is_active', $condition, 'title'); | |
1181 | } | |
1182 | ||
1183 | return self::$staticGroup; | |
1184 | } | |
1185 | ||
1186 | /** | |
1187 | * Get all the custom groups | |
1188 | * | |
1189 | * @access public | |
1190 | * | |
1191 | * @return array - array reference of all groups. | |
1192 | * @static | |
1193 | */ | |
1194 | public static function &customGroup($reset = FALSE) { | |
1195 | if (!self::$customGroup || $reset) { | |
1196 | self::populate(self::$customGroup, 'CRM_Core_DAO_CustomGroup', FALSE, 'title', 'is_active', NULL, 'title'); | |
1197 | } | |
1198 | return self::$customGroup; | |
1199 | } | |
1200 | ||
1201 | /** | |
1202 | * Get all the user framework groups | |
1203 | * | |
1204 | * @access public | |
1205 | * | |
1206 | * @return array - array reference of all groups. | |
1207 | * @static | |
1208 | */ | |
1209 | public static function &ufGroup() { | |
1210 | if (!self::$ufGroup) { | |
1211 | self::populate(self::$ufGroup, 'CRM_Core_DAO_UFGroup', FALSE, 'title', 'is_active', NULL, 'title'); | |
1212 | } | |
1213 | return self::$ufGroup; | |
1214 | } | |
1215 | ||
1216 | /** | |
1217 | * Get all the project tasks | |
1218 | * | |
1219 | * @access public | |
1220 | * | |
1221 | * @return array - array reference of all tasks | |
1222 | * @static | |
1223 | */ | |
1224 | public static function &tasks() { | |
1225 | if (!self::$tasks) { | |
1226 | self::populate(self::$tasks, 'CRM_Project_DAO_Task', FALSE, 'title', 'is_active', NULL, 'title'); | |
1227 | } | |
1228 | return self::$tasks; | |
1229 | } | |
1230 | ||
1231 | /** | |
1232 | * Get all Relationship Types from database. | |
1233 | * | |
1234 | * The static array group is returned, and if it's | |
1235 | * called the first time, the <b>RelationshipType DAO</b> is used | |
1236 | * to get all the relationship types. | |
1237 | * | |
1238 | * Note: any database errors will be trapped by the DAO. | |
1239 | * | |
1240 | * @param string $valueColumnName db column name/label. | |
1241 | * @param boolean $reset reset relationship types if true | |
1242 | * | |
1243 | * @access public | |
1244 | * @static | |
1245 | * | |
1246 | * @return array - array reference of all relationship types. | |
1247 | */ | |
1248 | public static function &relationshipType($valueColumnName = 'label', $reset = FALSE) { | |
1249 | if (!CRM_Utils_Array::value($valueColumnName, self::$relationshipType) || $reset) { | |
1250 | self::$relationshipType[$valueColumnName] = array(); | |
1251 | ||
1252 | //now we have name/label columns CRM-3336 | |
1253 | $column_a_b = "{$valueColumnName}_a_b"; | |
1254 | $column_b_a = "{$valueColumnName}_b_a"; | |
1255 | ||
1256 | $relationshipTypeDAO = new CRM_Contact_DAO_RelationshipType(); | |
1257 | $relationshipTypeDAO->selectAdd(); | |
1258 | $relationshipTypeDAO->selectAdd("id, {$column_a_b}, {$column_b_a}, contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b"); | |
1259 | $relationshipTypeDAO->is_active = 1; | |
1260 | $relationshipTypeDAO->find(); | |
1261 | while ($relationshipTypeDAO->fetch()) { | |
1262 | ||
1263 | self::$relationshipType[$valueColumnName][$relationshipTypeDAO->id] = array( | |
1264 | $column_a_b => $relationshipTypeDAO->$column_a_b, | |
1265 | $column_b_a => $relationshipTypeDAO->$column_b_a, | |
1266 | 'contact_type_a' => "$relationshipTypeDAO->contact_type_a", | |
1267 | 'contact_type_b' => "$relationshipTypeDAO->contact_type_b", | |
1268 | 'contact_sub_type_a' => "$relationshipTypeDAO->contact_sub_type_a", | |
1269 | 'contact_sub_type_b' => "$relationshipTypeDAO->contact_sub_type_b", | |
1270 | ); | |
1271 | } | |
1272 | } | |
1273 | ||
1274 | return self::$relationshipType[$valueColumnName]; | |
1275 | } | |
1276 | ||
1277 | /** | |
1278 | * Get all the Currency Symbols from Database | |
1279 | * | |
1280 | * @access public | |
1281 | * | |
1282 | * @return array - array reference of all Currency Symbols | |
1283 | * @static | |
1284 | */ | |
1285 | public static function ¤cySymbols($name = 'symbol', $key = 'id') { | |
1286 | $cacheKey = "{$name}_{$key}"; | |
1287 | if (!isset(self::$currencySymbols[$cacheKey])) { | |
1288 | self::populate(self::$currencySymbols[$cacheKey], 'CRM_Financial_DAO_Currency', TRUE, $name, NULL, NULL, 'name', $key); | |
1289 | } | |
1290 | ||
1291 | return self::$currencySymbols[$cacheKey]; | |
1292 | } | |
1293 | ||
1294 | /** | |
1295 | * get all the ISO 4217 currency codes | |
1296 | * | |
1297 | * so far, we use this for validation only, so there's no point of putting this into the database | |
1298 | * | |
1299 | * @access public | |
1300 | * | |
1301 | * @return array - array reference of all currency codes | |
1302 | * @static | |
1303 | */ | |
1304 | public static function ¤cyCode() { | |
1305 | if (!self::$currencyCode) { | |
1306 | self::$currencyCode = array( | |
1307 | 'AFN', | |
1308 | 'ALL', | |
1309 | 'DZD', | |
1310 | 'USD', | |
1311 | 'EUR', | |
1312 | 'AOA', | |
1313 | 'XCD', | |
1314 | 'XCD', | |
1315 | 'ARS', | |
1316 | 'AMD', | |
1317 | 'AWG', | |
1318 | 'AUD', | |
1319 | 'EUR', | |
1320 | 'AZM', | |
1321 | 'BSD', | |
1322 | 'BHD', | |
1323 | 'BDT', | |
1324 | 'BBD', | |
1325 | 'BYR', | |
1326 | 'EUR', | |
1327 | 'BZD', | |
1328 | 'XOF', | |
1329 | 'BMD', | |
1330 | 'INR', | |
1331 | 'BTN', | |
1332 | 'BOB', | |
1333 | 'BOV', | |
1334 | 'BAM', | |
1335 | 'BWP', | |
1336 | 'NOK', | |
1337 | 'BRL', | |
1338 | 'USD', | |
1339 | 'BND', | |
1340 | 'BGN', | |
1341 | 'XOF', | |
1342 | 'BIF', | |
1343 | 'KHR', | |
1344 | 'XAF', | |
1345 | 'CAD', | |
1346 | 'CVE', | |
1347 | 'KYD', | |
1348 | 'XAF', | |
1349 | 'XAF', | |
1350 | 'CLP', | |
1351 | 'CLF', | |
1352 | 'CNY', | |
1353 | 'AUD', | |
1354 | 'AUD', | |
1355 | 'COP', | |
1356 | 'COU', | |
1357 | 'KMF', | |
1358 | 'XAF', | |
1359 | 'CDF', | |
1360 | 'NZD', | |
1361 | 'CRC', | |
1362 | 'XOF', | |
1363 | 'HRK', | |
1364 | 'CUP', | |
1365 | 'CYP', | |
1366 | 'CZK', | |
1367 | 'DKK', | |
1368 | 'DJF', | |
1369 | 'XCD', | |
1370 | 'DOP', | |
1371 | 'USD', | |
1372 | 'EGP', | |
1373 | 'SVC', | |
1374 | 'USD', | |
1375 | 'XAF', | |
1376 | 'ERN', | |
1377 | 'EEK', | |
1378 | 'ETB', | |
1379 | 'FKP', | |
1380 | 'DKK', | |
1381 | 'FJD', | |
1382 | 'EUR', | |
1383 | 'EUR', | |
1384 | 'EUR', | |
1385 | 'XPF', | |
1386 | 'EUR', | |
1387 | 'XAF', | |
1388 | 'GMD', | |
1389 | 'GEL', | |
1390 | 'EUR', | |
1391 | 'GHC', | |
1392 | 'GIP', | |
1393 | 'EUR', | |
1394 | 'DKK', | |
1395 | 'XCD', | |
1396 | 'EUR', | |
1397 | 'USD', | |
1398 | 'GTQ', | |
1399 | 'GNF', | |
1400 | 'GWP', | |
1401 | 'XOF', | |
1402 | 'GYD', | |
1403 | 'HTG', | |
1404 | 'USD', | |
1405 | 'AUD', | |
1406 | 'EUR', | |
1407 | 'HNL', | |
1408 | 'HKD', | |
1409 | 'HUF', | |
1410 | 'ISK', | |
1411 | 'INR', | |
1412 | 'IDR', | |
1413 | 'XDR', | |
1414 | 'IRR', | |
1415 | 'IQD', | |
1416 | 'EUR', | |
1417 | 'ILS', | |
1418 | 'EUR', | |
1419 | 'JMD', | |
1420 | 'JPY', | |
1421 | 'JOD', | |
1422 | 'KZT', | |
1423 | 'KES', | |
1424 | 'AUD', | |
1425 | 'KPW', | |
1426 | 'KRW', | |
1427 | 'KWD', | |
1428 | 'KGS', | |
1429 | 'LAK', | |
1430 | 'LVL', | |
1431 | 'LBP', | |
1432 | 'ZAR', | |
1433 | 'LSL', | |
1434 | 'LRD', | |
1435 | 'LYD', | |
1436 | 'CHF', | |
1437 | 'LTL', | |
1438 | 'EUR', | |
1439 | 'MOP', | |
1440 | 'MKD', | |
1441 | 'MGA', | |
1442 | 'MWK', | |
1443 | 'MYR', | |
1444 | 'MVR', | |
1445 | 'XOF', | |
1446 | 'MTL', | |
1447 | 'USD', | |
1448 | 'EUR', | |
1449 | 'MRO', | |
1450 | 'MUR', | |
1451 | 'EUR', | |
1452 | 'MXN', | |
1453 | 'MXV', | |
1454 | 'USD', | |
1455 | 'MDL', | |
1456 | 'EUR', | |
1457 | 'MNT', | |
1458 | 'XCD', | |
1459 | 'MAD', | |
1460 | 'MZM', | |
1461 | 'MMK', | |
1462 | 'ZAR', | |
1463 | 'NAD', | |
1464 | 'AUD', | |
1465 | 'NPR', | |
1466 | 'EUR', | |
1467 | 'ANG', | |
1468 | 'XPF', | |
1469 | 'NZD', | |
1470 | 'NIO', | |
1471 | 'XOF', | |
1472 | 'NGN', | |
1473 | 'NZD', | |
1474 | 'AUD', | |
1475 | 'USD', | |
1476 | 'NOK', | |
1477 | 'OMR', | |
1478 | 'PKR', | |
1479 | 'USD', | |
1480 | 'PAB', | |
1481 | 'USD', | |
1482 | 'PGK', | |
1483 | 'PYG', | |
1484 | 'PEN', | |
1485 | 'PHP', | |
1486 | 'NZD', | |
1487 | 'PLN', | |
1488 | 'EUR', | |
1489 | 'USD', | |
1490 | 'QAR', | |
1491 | 'EUR', | |
1492 | 'ROL', | |
1493 | 'RON', | |
1494 | 'RUB', | |
1495 | 'RWF', | |
1496 | 'SHP', | |
1497 | 'XCD', | |
1498 | 'XCD', | |
1499 | 'EUR', | |
1500 | 'XCD', | |
1501 | 'WST', | |
1502 | 'EUR', | |
1503 | 'STD', | |
1504 | 'SAR', | |
1505 | 'XOF', | |
1506 | 'CSD', | |
1507 | 'EUR', | |
1508 | 'SCR', | |
1509 | 'SLL', | |
1510 | 'SGD', | |
1511 | 'SKK', | |
1512 | 'SIT', | |
1513 | 'SBD', | |
1514 | 'SOS', | |
1515 | 'ZAR', | |
1516 | 'EUR', | |
1517 | 'LKR', | |
1518 | 'SDD', | |
1519 | 'SRD', | |
1520 | 'NOK', | |
1521 | 'SZL', | |
1522 | 'SEK', | |
1523 | 'CHF', | |
1524 | 'CHW', | |
1525 | 'CHE', | |
1526 | 'SYP', | |
1527 | 'TWD', | |
1528 | 'TJS', | |
1529 | 'TZS', | |
1530 | 'THB', | |
1531 | 'USD', | |
1532 | 'XOF', | |
1533 | 'NZD', | |
1534 | 'TOP', | |
1535 | 'TTD', | |
1536 | 'TND', | |
1537 | 'TRY', | |
1538 | 'TRL', | |
1539 | 'TMM', | |
1540 | 'USD', | |
1541 | 'AUD', | |
1542 | 'UGX', | |
1543 | 'UAH', | |
1544 | 'AED', | |
1545 | 'GBP', | |
1546 | 'USD', | |
1547 | 'USS', | |
1548 | 'USN', | |
1549 | 'USD', | |
1550 | 'UYU', | |
1551 | 'UZS', | |
1552 | 'VUV', | |
1553 | 'VEB', | |
1554 | 'VND', | |
1555 | 'USD', | |
1556 | 'USD', | |
1557 | 'XPF', | |
1558 | 'MAD', | |
1559 | 'YER', | |
1560 | 'ZMK', | |
1561 | 'ZWD', | |
1562 | 'XAU', | |
1563 | 'XBA', | |
1564 | 'XBB', | |
1565 | 'XBC', | |
1566 | 'XBD', | |
1567 | 'XPD', | |
1568 | 'XPT', | |
1569 | 'XAG', | |
1570 | 'XFU', | |
1571 | 'XFO', | |
1572 | 'XTS', | |
1573 | 'XXX', | |
1574 | ); | |
1575 | } | |
1576 | return self::$currencyCode; | |
1577 | } | |
1578 | ||
1579 | /** | |
1580 | * Get all the County from database. | |
1581 | * | |
1582 | * The static array county is returned, and if it's | |
1583 | * called the first time, the <b>County DAO</b> is used | |
1584 | * to get all the Counties. | |
1585 | * | |
1586 | * Note: any database errors will be trapped by the DAO. | |
1587 | * | |
1588 | * @access public | |
1589 | * @static | |
1590 | * | |
1591 | * @param int $id - Optional id to return | |
1592 | * | |
1593 | * @return array - array reference of all Counties | |
1594 | * | |
1595 | */ | |
1596 | public static function &county($id = FALSE) { | |
1597 | if (!self::$county) { | |
1598 | ||
1599 | $config = CRM_Core_Config::singleton(); | |
1600 | // order by id so users who populate civicrm_county can have more control over sort by the order they load the counties | |
1601 | self::populate(self::$county, 'CRM_Core_DAO_County', TRUE, 'name', NULL, NULL, 'id'); | |
1602 | } | |
1603 | if ($id) { | |
1604 | if (array_key_exists($id, self::$county)) { | |
1605 | return self::$county[$id]; | |
1606 | } | |
1607 | else { | |
1608 | return NULL; | |
1609 | } | |
1610 | } | |
1611 | return self::$county; | |
1612 | } | |
1613 | ||
1614 | /** | |
1615 | * Get all the Preferred Communication Methods from database. | |
1616 | * | |
1617 | * @access public | |
1618 | * @static | |
1619 | * | |
1620 | * @return array self::pcm - array reference of all preferred communication methods. | |
1621 | * | |
1622 | */ | |
1623 | public static function &pcm($localize = FALSE) { | |
1624 | if (!self::$pcm) { | |
1625 | self::$pcm = CRM_Core_OptionGroup::values('preferred_communication_method', FALSE, FALSE, $localize); | |
1626 | } | |
1627 | return self::$pcm; | |
1628 | } | |
1629 | ||
1630 | /** | |
1631 | * Alias of pcm | |
1632 | */ | |
1633 | public static function preferredCommunicationMethod($localize = FALSE) { | |
1634 | return self::pcm($localize); | |
1635 | } | |
1636 | ||
1637 | /** | |
1638 | * Get all active payment processors | |
1639 | * | |
1640 | * The static array paymentProcessor is returned | |
1641 | * | |
1642 | * @access public | |
1643 | * @static | |
1644 | * | |
1645 | * @param boolean $all - get payment processors - default is to get only active ones. | |
1646 | * @param boolean $test - get test payment processors | |
1647 | * | |
1648 | * @return array - array of all payment processors | |
1649 | * | |
1650 | */ | |
1651 | public static function &paymentProcessor($all = FALSE, $test = FALSE, $additionalCond = NULL) { | |
1652 | $condition = "is_test = "; | |
1653 | $condition .= ($test) ? '1' : '0'; | |
1654 | ||
1655 | if ($additionalCond) { | |
1656 | $condition .= " AND ( $additionalCond ) "; | |
1657 | } | |
1658 | ||
1659 | // CRM-7178. Make sure we only include payment processors valid in ths | |
1660 | // domain | |
1661 | $condition .= " AND domain_id = " . CRM_Core_Config::domainID(); | |
1662 | ||
1663 | $cacheKey = $condition . '_' . (int) $all; | |
1664 | if (!isset(self::$paymentProcessor[$cacheKey])) { | |
1665 | self::populate(self::$paymentProcessor[$cacheKey], 'CRM_Financial_DAO_PaymentProcessor', $all, 'name', 'is_active', $condition, 'is_default desc, name'); | |
1666 | } | |
1667 | ||
1668 | return self::$paymentProcessor[$cacheKey]; | |
1669 | } | |
1670 | ||
1671 | /** | |
1672 | * Get all active payment processors | |
1673 | * | |
1674 | * The static array paymentProcessorType is returned | |
1675 | * | |
1676 | * @access public | |
1677 | * @static | |
1678 | * | |
1679 | * @param boolean $all - get payment processors - default is to get only active ones. | |
1680 | * | |
1681 | * @return array - array of all payment processor types | |
1682 | * | |
1683 | */ | |
1684 | public static function &paymentProcessorType($all = FALSE, $id = NULL, $return = 'title') { | |
1685 | $cacheKey = $id . '_' .$return; | |
1686 | if (empty(self::$paymentProcessorType[$cacheKey])) { | |
1687 | self::populate(self::$paymentProcessorType[$cacheKey], 'CRM_Financial_DAO_PaymentProcessorType', $all, $return, 'is_active', NULL, "is_default, $return", 'id'); | |
1688 | } | |
1689 | if ($id && CRM_Utils_Array::value($id, self::$paymentProcessorType[$cacheKey])) { | |
1690 | return self::$paymentProcessorType[$cacheKey][$id]; | |
1691 | } | |
1692 | return self::$paymentProcessorType[$cacheKey]; | |
1693 | } | |
1694 | ||
1695 | /** | |
1696 | * Get all the World Regions from Database | |
1697 | * | |
1698 | * @access public | |
1699 | * | |
1700 | * @return array - array reference of all World Regions | |
1701 | * @static | |
1702 | */ | |
1703 | public static function &worldRegion($id = FALSE) { | |
1704 | if (!self::$worldRegions) { | |
1705 | self::populate(self::$worldRegions, 'CRM_Core_DAO_Worldregion', TRUE, 'name', NULL, NULL, 'id'); | |
1706 | } | |
1707 | ||
1708 | if ($id) { | |
1709 | if (array_key_exists($id, self::$worldRegions)) { | |
1710 | return self::$worldRegions[$id]; | |
1711 | } | |
1712 | else { | |
1713 | return NULL; | |
1714 | } | |
1715 | } | |
1716 | ||
1717 | return self::$worldRegions; | |
1718 | } | |
1719 | ||
1720 | /** | |
1721 | * Get all Honor Type. | |
1722 | * | |
1723 | * The static array honorType is returned | |
1724 | * | |
1725 | * @access public | |
1726 | * @static | |
1727 | * | |
1728 | * @param boolean $all - get All Honor Type. | |
1729 | * | |
1730 | * @return array - array reference of all Honor Types. | |
1731 | * | |
1732 | */ | |
1733 | public static function &honor() { | |
1734 | if (!self::$honorType) { | |
1735 | self::$honorType = CRM_Core_OptionGroup::values('honor_type'); | |
1736 | } | |
1737 | return self::$honorType; | |
1738 | } | |
1739 | ||
1740 | /** | |
1741 | * Get all Activity Statuses. | |
1742 | * | |
1743 | * The static array activityStatus is returned | |
1744 | * | |
1745 | * @access public | |
1746 | * @static | |
1747 | * | |
1748 | * @return array - array reference of all activity statuses | |
1749 | */ | |
1750 | public static function &activityStatus($column = 'label') { | |
1751 | if (NULL === self::$activityStatus) { | |
1752 | self::$activityStatus = array(); | |
1753 | } | |
1754 | if (!array_key_exists($column, self::$activityStatus)) { | |
1755 | self::$activityStatus[$column] = array(); | |
1756 | ||
1757 | self::$activityStatus[$column] = CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, $column); | |
1758 | } | |
1759 | ||
1760 | return self::$activityStatus[$column]; | |
1761 | } | |
1762 | ||
1763 | /** | |
1764 | * Get all Priorities | |
1765 | * | |
1766 | * The static array Priority is returned | |
1767 | * | |
1768 | * @access public | |
1769 | * @static | |
1770 | * | |
1771 | * @return array - array reference of all Priority | |
1772 | */ | |
1773 | public static function &priority() { | |
1774 | if (!self::$priority) { | |
1775 | self::$priority = CRM_Core_OptionGroup::values('priority'); | |
1776 | } | |
1777 | ||
1778 | return self::$priority; | |
1779 | } | |
1780 | ||
1781 | /** | |
1782 | * Get all WYSIWYG Editors. | |
1783 | * | |
1784 | * The static array wysiwygEditor is returned | |
1785 | * | |
1786 | * @access public | |
1787 | * @static | |
1788 | * | |
1789 | * @return array - array reference of all wysiwygEditors | |
1790 | */ | |
1791 | public static function &wysiwygEditor() { | |
1792 | if (!self::$wysiwygEditor) { | |
1793 | self::$wysiwygEditor = CRM_Core_OptionGroup::values('wysiwyg_editor'); | |
1794 | } | |
1795 | return self::$wysiwygEditor; | |
1796 | } | |
1797 | ||
1798 | /** | |
1799 | * Get all Visibility levels. | |
1800 | * | |
1801 | * The static array visibility is returned | |
1802 | * | |
1803 | * @access public | |
1804 | * @static | |
1805 | * | |
1806 | * @return array - array reference of all Visibility levels. | |
1807 | * | |
1808 | */ | |
1809 | public static function &visibility($column = 'label') { | |
1810 | if (!isset(self::$visibility)) { | |
1811 | self::$visibility = array( ); | |
1812 | } | |
1813 | ||
1814 | if (!isset(self::$visibility[$column])) { | |
1815 | self::$visibility[$column] = CRM_Core_OptionGroup::values('visibility', FALSE, FALSE, FALSE, NULL, $column); | |
1816 | } | |
1817 | ||
1818 | return self::$visibility[$column]; | |
1819 | } | |
1820 | ||
1821 | /** | |
1822 | * Get all mapping types | |
1823 | * | |
1824 | * @return array - array reference of all mapping types | |
1825 | * @access public | |
1826 | * @static | |
1827 | */ | |
1828 | public static function &mappingTypes() { | |
1829 | if (!self::$mappingType) { | |
1830 | self::$mappingType = CRM_Core_OptionGroup::values('mapping_type'); | |
1831 | } | |
1832 | return self::$mappingType; | |
1833 | } | |
1834 | ||
1835 | public static function &stateProvinceForCountry($countryID, $field = 'name') { | |
1836 | static $_cache = NULL; | |
1837 | ||
1838 | $cacheKey = "{$countryID}_{$field}"; | |
1839 | if (!$_cache) { | |
1840 | $_cache = array(); | |
1841 | } | |
1842 | ||
1843 | if (!empty($_cache[$cacheKey])) { | |
1844 | return $_cache[$cacheKey]; | |
1845 | } | |
1846 | ||
1847 | $query = " | |
1848 | SELECT civicrm_state_province.{$field} name, civicrm_state_province.id id | |
1849 | FROM civicrm_state_province | |
1850 | WHERE country_id = %1 | |
1851 | ORDER BY name"; | |
1852 | $params = array( | |
1853 | 1 => array( | |
1854 | $countryID, | |
1855 | 'Integer', | |
1856 | ), | |
1857 | ); | |
1858 | ||
1859 | $dao = CRM_Core_DAO::executeQuery($query, $params); | |
1860 | ||
1861 | $result = array(); | |
1862 | while ($dao->fetch()) { | |
1863 | $result[$dao->id] = $dao->name; | |
1864 | } | |
1865 | ||
1866 | // localise the stateProvince names if in an non-en_US locale | |
1867 | $config = CRM_Core_Config::singleton(); | |
1868 | global $tsLocale; | |
1869 | if ($tsLocale != '' and $tsLocale != 'en_US') { | |
1870 | $i18n = CRM_Core_I18n::singleton(); | |
1871 | $i18n->localizeArray($result, array( | |
1872 | 'context' => 'province', | |
1873 | )); | |
1874 | $result = CRM_Utils_Array::asort($result); | |
1875 | } | |
1876 | ||
1877 | $_cache[$cacheKey] = $result; | |
1878 | ||
1879 | CRM_Utils_Hook::buildStateProvinceForCountry($countryID, $result); | |
1880 | ||
1881 | return $result; | |
1882 | } | |
1883 | ||
1884 | public static function &countyForState($stateID) { | |
1885 | if (is_array($stateID)) { | |
1886 | $states = implode(", ", $stateID); | |
1887 | $query = " | |
1888 | SELECT civicrm_county.name name, civicrm_county.id id, civicrm_state_province.abbreviation abbreviation | |
1889 | FROM civicrm_county | |
1890 | LEFT JOIN civicrm_state_province ON civicrm_county.state_province_id = civicrm_state_province.id | |
1891 | WHERE civicrm_county.state_province_id in ( $states ) | |
1892 | ORDER BY civicrm_state_province.abbreviation, civicrm_county.name"; | |
1893 | ||
1894 | $dao = CRM_Core_DAO::executeQuery($query); | |
1895 | ||
1896 | $result = array(); | |
1897 | while ($dao->fetch()) { | |
1898 | $result[$dao->id] = $dao->abbreviation . ': ' . $dao->name; | |
1899 | } | |
1900 | } | |
1901 | else { | |
1902 | ||
1903 | static $_cache = NULL; | |
1904 | ||
1905 | $cacheKey = "{$stateID}_name"; | |
1906 | if (!$_cache) { | |
1907 | $_cache = array(); | |
1908 | } | |
1909 | ||
1910 | if (!empty($_cache[$cacheKey])) { | |
1911 | return $_cache[$cacheKey]; | |
1912 | } | |
1913 | ||
1914 | $query = " | |
1915 | SELECT civicrm_county.name name, civicrm_county.id id | |
1916 | FROM civicrm_county | |
1917 | WHERE state_province_id = %1 | |
1918 | ORDER BY name"; | |
1919 | $params = array( | |
1920 | 1 => array( | |
1921 | $stateID, | |
1922 | 'Integer', | |
1923 | ), | |
1924 | ); | |
1925 | ||
1926 | $dao = CRM_Core_DAO::executeQuery($query, $params); | |
1927 | ||
1928 | $result = array(); | |
1929 | while ($dao->fetch()) { | |
1930 | $result[$dao->id] = $dao->name; | |
1931 | } | |
1932 | } | |
1933 | ||
1934 | return $result; | |
1935 | } | |
1936 | ||
b05e28de DL |
1937 | /** |
1938 | * Given a state ID return the country ID, this allows | |
1939 | * us to populate forms and values for downstream code | |
1940 | * | |
1941 | * @param $stateID int | |
1942 | * | |
1943 | * @return int the country id that the state belongs to | |
1944 | * @static | |
1945 | * @public | |
1946 | */ | |
1947 | static function countryIDForStateID($stateID) { | |
1948 | if (empty($stateID)) { | |
1949 | return NULL; | |
1950 | } | |
1951 | ||
1952 | $query = " | |
1953 | SELECT country_id | |
1954 | FROM civicrm_state_province | |
1955 | WHERE id = %1 | |
1956 | "; | |
1957 | $params = array(1 => array($stateID, 'Integer')); | |
1958 | ||
1959 | return CRM_Core_DAO::singleValueQuery($query, $params); | |
1960 | } | |
1961 | ||
6a488035 TO |
1962 | /** |
1963 | * Get all types of Greetings. | |
1964 | * | |
1965 | * The static array of greeting is returned | |
1966 | * | |
1967 | * @access public | |
1968 | * @static | |
1969 | * | |
1970 | * @param $filter - get All Email Greetings - default is to get only active ones. | |
1971 | * | |
1972 | * @return array - array reference of all greetings. | |
1973 | * | |
1974 | */ | |
1975 | public static function greeting($filter, $columnName = 'label') { | |
1976 | $index = $filter['greeting_type'] . '_' . $columnName; | |
1977 | ||
1978 | // also add contactType to the array | |
1979 | $contactType = CRM_Utils_Array::value('contact_type', $filter); | |
1980 | if ($contactType) { | |
1981 | $index .= '_' . $contactType; | |
1982 | } | |
1983 | ||
1984 | if (NULL === self::$greeting) { | |
1985 | self::$greeting = array(); | |
1986 | } | |
1987 | ||
1988 | if (!CRM_Utils_Array::value($index, self::$greeting)) { | |
1989 | $filterCondition = NULL; | |
1990 | if ($contactType) { | |
1991 | $filterVal = 'v.filter ='; | |
1992 | switch ($contactType) { | |
1993 | case 'Individual': | |
1994 | $filterVal .= "1"; | |
1995 | break; | |
1996 | ||
1997 | case 'Household': | |
1998 | $filterVal .= "2"; | |
1999 | break; | |
2000 | ||
2001 | case 'Organization': | |
2002 | $filterVal .= "3"; | |
2003 | break; | |
2004 | } | |
2005 | $filterCondition .= "AND (v.filter = 0 OR {$filterVal}) "; | |
2006 | } | |
2007 | ||
2008 | self::$greeting[$index] = CRM_Core_OptionGroup::values($filter['greeting_type'], NULL, NULL, NULL, $filterCondition, $columnName); | |
2009 | } | |
2010 | ||
2011 | return self::$greeting[$index]; | |
2012 | } | |
2013 | ||
2014 | /** | |
2015 | * Construct array of default greeting values for contact type | |
2016 | * | |
2017 | * @access public | |
2018 | * @static | |
2019 | * | |
2020 | * @return array - array reference of default greetings. | |
2021 | * | |
2022 | */ | |
2023 | public static function &greetingDefaults() { | |
2024 | if (!self::$greetingDefaults) { | |
2025 | $defaultGreetings = array(); | |
2026 | $contactTypes = array( | |
2027 | 'Individual' => 1, | |
2028 | 'Household' => 2, | |
2029 | 'Organization' => 3, | |
2030 | ); | |
2031 | ||
2032 | foreach ($contactTypes as $contactType => $filter) { | |
2033 | $filterCondition = " AND (v.filter = 0 OR v.filter = $filter) AND v.is_default = 1 "; | |
2034 | ||
2035 | foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) { | |
2036 | $tokenVal = CRM_Core_OptionGroup::values($greeting, NULL, NULL, NULL, $filterCondition, 'label'); | |
2037 | $defaultGreetings[$contactType][$greeting] = $tokenVal; | |
2038 | } | |
2039 | } | |
2040 | ||
2041 | self::$greetingDefaults = $defaultGreetings; | |
2042 | } | |
2043 | ||
2044 | return self::$greetingDefaults; | |
2045 | } | |
2046 | ||
2047 | /** | |
2048 | * Get all the Languages from database. | |
2049 | * | |
2050 | * @access public | |
2051 | * @static | |
2052 | * | |
2053 | * @return array self::languages - array reference of all languages | |
2054 | * | |
2055 | */ | |
2056 | public static function &languages() { | |
2057 | return CRM_Core_I18n_PseudoConstant::languages(); | |
2058 | } | |
2059 | ||
2060 | /** | |
2061 | * Alias of above | |
2062 | */ | |
2063 | public static function &preferredLanguage() { | |
2064 | return CRM_Core_I18n_PseudoConstant::languages(); | |
2065 | } | |
2066 | ||
2067 | /** | |
2068 | * Get all extensions | |
2069 | * | |
2070 | * The static array extensions | |
2071 | * | |
2072 | * FIXME: This is called by civix but not by any core code. We | |
2073 | * should provide an API call which civix can use instead. | |
2074 | * | |
2075 | * @access public | |
2076 | * @static | |
2077 | * | |
2078 | * @return array - array($fullyQualifiedName => $label) list of extensions | |
2079 | */ | |
2080 | public static function &getExtensions() { | |
2081 | if (!self::$extensions) { | |
2082 | self::$extensions = array(); | |
2083 | $sql = ' | |
2084 | SELECT full_name, label | |
2085 | FROM civicrm_extension | |
2086 | WHERE is_active = 1 | |
2087 | '; | |
2088 | $dao = CRM_Core_DAO::executeQuery($sql); | |
2089 | while ($dao->fetch()) { | |
2090 | self::$extensions[$dao->full_name] = $dao->label; | |
2091 | } | |
2092 | } | |
2093 | ||
2094 | return self::$extensions; | |
2095 | } | |
2096 | ||
2097 | /** | |
2098 | * Fetch the list of active extensions of type 'module' | |
2099 | * | |
2100 | * @param $fresh bool whether to forcibly reload extensions list from canonical store | |
2101 | * @access public | |
2102 | * @static | |
2103 | * | |
2104 | * @return array - array(array('prefix' => $, 'file' => $)) | |
2105 | */ | |
2106 | public static function getModuleExtensions($fresh = FALSE) { | |
2107 | return CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles($fresh); | |
2108 | } | |
2109 | ||
2110 | /** | |
2111 | * Get all Activity Contacts | |
2112 | * | |
2113 | * The static array activityContacts is returned | |
2114 | * | |
2115 | * @access public | |
2116 | * @static | |
2117 | * | |
2118 | * @param string $column db column name/label. | |
2119 | * | |
2120 | * @return array - array reference of all activity Contacts | |
2121 | * | |
2122 | */ | |
2123 | public static function &activityContacts($column = 'label') { | |
2124 | if (!self::$activityContacts) { | |
2125 | self::$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, $column); | |
2126 | } | |
2127 | return self::$activityContacts; | |
2128 | } | |
2129 | ||
2130 | /** | |
2131 | * Get all Event Contacts | |
2132 | * | |
2133 | * The static array eventContacts is returned | |
2134 | * | |
2135 | * @access public | |
2136 | * @static | |
2137 | * | |
2138 | * @param string $column db column name/label. | |
2139 | * | |
2140 | * @return array - array reference of all event Contacts | |
2141 | * | |
2142 | */ | |
2143 | public static function &eventContacts($column = 'label') { | |
2144 | if (!self::$eventContacts) { | |
2145 | self::$eventContacts = CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, $column); | |
2146 | } | |
2147 | return self::$eventContacts; | |
2148 | } | |
2149 | ||
2150 | /** | |
2151 | * Get all options values | |
2152 | * | |
2153 | * The static array option values is returned | |
2154 | * | |
2155 | * @access public | |
2156 | * @static | |
2157 | * | |
2158 | * @param boolean $optionGroupName - get All Option Group values- default is to get only active ones. | |
2159 | * | |
2160 | * @return array - array reference of all Option Group Name | |
2161 | * | |
2162 | */ | |
2163 | public static function accountOptionValues($optionGroupName, $id = null, $condition = null) { | |
2164 | $cacheKey = $optionGroupName . '_' . $condition; | |
2165 | if (empty(self::$accountOptionValues[$cacheKey])) { | |
2166 | self::$accountOptionValues[$cacheKey] = CRM_Core_OptionGroup::values($optionGroupName, false, false, false, $condition); | |
2167 | } | |
2168 | if ($id) { | |
2169 | return CRM_Utils_Array::value($id, self::$accountOptionValues[$cacheKey]); | |
2170 | } | |
2171 | ||
2172 | return self::$accountOptionValues[$cacheKey]; | |
2173 | } | |
2174 | ||
2175 | /** | |
2176 | * Get all batch modes | |
2177 | * | |
2178 | * The static array batchModes | |
2179 | * | |
2180 | * @access public | |
2181 | * @static | |
2182 | * | |
2183 | * @return array - array reference of all batch modes | |
2184 | */ | |
2185 | public static function &getBatchMode($columnName = 'label') { | |
2186 | if (!self::$batchModes) { | |
2187 | self::$batchModes = CRM_Core_OptionGroup::values('batch_mode', false, false, false, null, $columnName); | |
2188 | } | |
2189 | ||
2190 | return self::$batchModes; | |
2191 | } | |
2192 | ||
2193 | /** | |
2194 | * Get all batch types | |
2195 | * | |
2196 | * The static array batchTypes | |
2197 | * | |
2198 | * @access public | |
2199 | * @static | |
2200 | * | |
2201 | * @return array - array reference of all batch types | |
2202 | */ | |
2203 | public static function &getBatchType() { | |
2204 | if (!self::$batchTypes) { | |
2205 | self::$batchTypes = CRM_Core_OptionGroup::values('batch_type'); | |
2206 | } | |
2207 | ||
2208 | return self::$batchTypes; | |
2209 | } | |
2210 | ||
2211 | /** | |
2212 | * Get all batch statuses | |
2213 | * | |
2214 | * The static array batchStatues | |
2215 | * | |
2216 | * @access public | |
2217 | * @static | |
2218 | * | |
2219 | * @return array - array reference of all batch statuses | |
2220 | */ | |
2221 | public static function &getBatchStatus() { | |
2222 | if (!self::$batchStatues) { | |
2223 | self::$batchStatues = CRM_Core_OptionGroup::values('batch_status'); | |
2224 | } | |
2225 | ||
2226 | return self::$batchStatues; | |
2227 | } | |
2228 | ||
2229 | /* | |
2230 | * The static array contactType is returned | |
2231 | * | |
2232 | * @access public | |
2233 | * @static | |
2234 | * @param string $column db column name/label. | |
2235 | * | |
2236 | * @return array - array reference of all Types | |
2237 | * | |
2238 | */ | |
2239 | ||
2240 | public static function &contactType($column = 'label') { | |
2241 | if (!self::$contactType) { | |
2242 | self::$contactType = CRM_Contact_BAO_ContactType::basicTypePairs(TRUE); | |
2243 | } | |
2244 | return self::$contactType; | |
2245 | } | |
2246 | ||
2247 | /** | |
2248 | * Get all the auto renew options | |
2249 | * | |
2250 | * @access public | |
2251 | * @static | |
2252 | * | |
2253 | * @return array self::autoRenew - array reference of all autoRenew | |
2254 | * | |
2255 | */ | |
2256 | public static function &autoRenew() { | |
2257 | if (!self::$autoRenew) { | |
2258 | self::$autoRenew = CRM_Core_OptionGroup::values('auto_renew_options', FALSE, FALSE); | |
2259 | } | |
2260 | return self::$autoRenew; | |
2261 | } | |
2262 | } | |
2263 |