INFRA-132 - s/(else|try){/(else|try) {/
[civicrm-core.git] / CRM / Campaign / PseudoConstant.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 * $Id$
33 *
34 */
35
36 /**
37 * This class holds all the Pseudo constants those
38 * are specific to Campaign and Survey.
39 */
40 class CRM_Campaign_PseudoConstant extends CRM_Core_PseudoConstant {
41
42 /**
43 * Activity types
44 * @var array
45 * @static
46 */
47 private static $activityType;
48
49 /**
50 * Campaign Type
51 * @var array
52 * @static
53 */
54 private static $campaignType = array();
55
56 /**
57 * Campaign Status
58 * @var array
59 * @static
60 */
61 private static $campaignStatus = array();
62
63 /**
64 * Engagement Level
65 * @static
66 */
67 private static $engagementLevel;
68
69 /**
70 * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
71 * Get all the survey activity types
72 *
73 *
74 * @param string $returnColumn
75 *
76 * @return array - array reference of all survey activity types.
77 * @static
78 */
79 public static function &activityType($returnColumn = 'name') {
80 $cacheKey = $returnColumn;
81 if (!isset(self::$activityType[$cacheKey])) {
82 $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
83 if ($campaingCompId) {
84 self::$activityType[$cacheKey] = CRM_Core_OptionGroup::values('activity_type',
85 FALSE, FALSE, FALSE,
86 " AND v.component_id={$campaingCompId}",
87 $returnColumn
88 );
89 }
90 }
91 asort(self::$activityType[$cacheKey]);
92 return self::$activityType[$cacheKey];
93 }
94
95 /**
96 * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
97 * Get all campaign types.
98 *
99 * The static array campaignType is returned
100 *
101 * @static
102 *
103 * @return array - array reference of all campaign types.
104 *
105 */
106 public static function &campaignType() {
107 if (!self::$campaignType) {
108 self::$campaignType = CRM_Core_OptionGroup::values('campaign_type');
109 }
110 asort(self::$campaignType);
111 return self::$campaignType;
112 }
113
114 /**
115 * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
116 * Get all campaign status.
117 *
118 * The static array campaignStatus is returned
119 *
120 * @static
121 *
122 * @return array - array reference of all campaign status.
123 *
124 */
125 public static function &campaignStatus() {
126 if (!self::$campaignStatus) {
127 self::$campaignStatus = CRM_Core_OptionGroup::values('campaign_status');
128 }
129 asort(self::$campaignStatus);
130 return self::$campaignStatus;
131 }
132
133 /**
134 * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
135 * Get all Engagement Level.
136 *
137 * The static array Engagement Level is returned
138 *
139 * @static
140 *
141 * @return array - array reference of all Engagement Level.
142 */
143 public static function &engagementLevel() {
144 if (!isset(self::$engagementLevel)) {
145 self::$engagementLevel = CRM_Core_OptionGroup::values('engagement_index');
146 }
147
148 return self::$engagementLevel;
149 }
150
151 /**
152 * Flush given pseudoconstant so it can be reread from db
153 * next time it's requested.
154 *
155 * @static
156 *
157 * @param bool|string $name pseudoconstant to be flushed
158 */
159 public static function flush($name = 'cache') {
160 if (isset(self::$$name)) {
161 self::$$name = NULL;
162 }
163 }
164 }