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