Merge pull request #247 from pradpnayak/CRM-12192
[civicrm-core.git] / CRM / Campaign / PseudoConstant.php
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 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
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 * Get all the survey activity types
71 *
72 * @access public
73 *
74 * @return array - array reference of all survey activity types.
75 * @static
76 */
77 public static function &activityType($returnColumn = 'name') {
78 $cacheKey = $returnColumn;
79 if (!isset(self::$activityType[$cacheKey])) {
80 $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
81 if ($campaingCompId) {
82 self::$activityType[$cacheKey] = CRM_Core_OptionGroup::values('activity_type',
83 FALSE, FALSE, FALSE,
84 " AND v.component_id={$campaingCompId}",
85 $returnColumn
86 );
87 }
88 }
89 asort(self::$activityType[$cacheKey]);
90 return self::$activityType[$cacheKey];
91 }
92
93 /**
94 * Get all campaign types.
95 *
96 * The static array campaignType is returned
97 *
98 * @access public
99 * @static
100 *
101 * @return array - array reference of all campaign types.
102 *
103 */
104 public static function &campaignType() {
105 if (!self::$campaignType) {
106 self::$campaignType = CRM_Core_OptionGroup::values('campaign_type');
107 }
108 asort(self::$campaignType);
109 return self::$campaignType;
110 }
111
112 /**
113 * Get all campaign status.
114 *
115 * The static array campaignStatus is returned
116 *
117 * @access public
118 * @static
119 *
120 * @return array - array reference of all campaign status.
121 *
122 */
123 public static function &campaignStatus() {
124 if (!self::$campaignStatus) {
125 self::$campaignStatus = CRM_Core_OptionGroup::values('campaign_status');
126 }
127 asort(self::$campaignStatus);
128 return self::$campaignStatus;
129 }
130
131 /**
132 * Get all Engagement Level.
133 *
134 * The static array Engagement Level is returned
135 *
136 * @access public
137 * @static
138 *
139 * @return array - array reference of all Engagement Level.
140 */
141 public static function &engagementLevel() {
142 if (!isset(self::$engagementLevel)) {
143 self::$engagementLevel = CRM_Core_OptionGroup::values('engagement_index');
144 }
145
146 return self::$engagementLevel;
147 }
148
149 /**
150 * Flush given pseudoconstant so it can be reread from db
151 * nex time it's requested.
152 *
153 * @access public
154 * @static
155 *
156 * @param boolean $name pseudoconstant to be flushed
157 *
158 */
159 public static function flush($name) {
160 self::$$name = NULL;
161 }
162 }
163