Merge pull request #18959 from seamuslee001/dev_core_2153_2
[civicrm-core.git] / CRM / Campaign / PseudoConstant.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
19 * This class holds all the Pseudo constants those
20 * are specific to Campaign and Survey.
21 */
22class CRM_Campaign_PseudoConstant extends CRM_Core_PseudoConstant {
23
24 /**
25 * Activity types
26 * @var array
6a488035
TO
27 */
28 private static $activityType;
29
30 /**
31 * Campaign Type
32 * @var array
6a488035 33 */
be2fb01f 34 private static $campaignType = [];
6a488035
TO
35
36 /**
37 * Campaign Status
38 * @var array
6a488035 39 */
be2fb01f 40 private static $campaignStatus = [];
6a488035
TO
41
42 /**
43 * Engagement Level
f157740d 44 * @var int
6a488035
TO
45 */
46 private static $engagementLevel;
47
48 /**
69af118f 49 * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
6a488035
TO
50 * Get all the survey activity types
51 *
dd244018
EM
52 * @param string $returnColumn
53 *
a6c01b45
CW
54 * @return array
55 * array reference of all survey activity types.
6a488035
TO
56 */
57 public static function &activityType($returnColumn = 'name') {
58 $cacheKey = $returnColumn;
59 if (!isset(self::$activityType[$cacheKey])) {
60 $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
61 if ($campaingCompId) {
62 self::$activityType[$cacheKey] = CRM_Core_OptionGroup::values('activity_type',
63 FALSE, FALSE, FALSE,
64 " AND v.component_id={$campaingCompId}",
65 $returnColumn
66 );
67 }
68 }
69 asort(self::$activityType[$cacheKey]);
70 return self::$activityType[$cacheKey];
71 }
72
73 /**
69af118f 74 * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
6a488035
TO
75 * Get all campaign types.
76 *
77 * The static array campaignType is returned
78 *
6a488035 79 *
a6c01b45
CW
80 * @return array
81 * array reference of all campaign types.
6a488035
TO
82 */
83 public static function &campaignType() {
84 if (!self::$campaignType) {
85 self::$campaignType = CRM_Core_OptionGroup::values('campaign_type');
86 }
87 asort(self::$campaignType);
88 return self::$campaignType;
89 }
90
91 /**
69af118f 92 * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
6a488035
TO
93 * Get all campaign status.
94 *
95 * The static array campaignStatus is returned
96 *
6a488035 97 *
a6c01b45
CW
98 * @return array
99 * array reference of all campaign status.
6a488035
TO
100 */
101 public static function &campaignStatus() {
102 if (!self::$campaignStatus) {
103 self::$campaignStatus = CRM_Core_OptionGroup::values('campaign_status');
104 }
105 asort(self::$campaignStatus);
106 return self::$campaignStatus;
107 }
108
109 /**
69af118f 110 * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
6a488035
TO
111 * Get all Engagement Level.
112 *
113 * The static array Engagement Level is returned
114 *
6a488035 115 *
a6c01b45
CW
116 * @return array
117 * array reference of all Engagement Level.
6a488035
TO
118 */
119 public static function &engagementLevel() {
120 if (!isset(self::$engagementLevel)) {
121 self::$engagementLevel = CRM_Core_OptionGroup::values('engagement_index');
122 }
123
124 return self::$engagementLevel;
125 }
126
127 /**
128 * Flush given pseudoconstant so it can be reread from db
3f3a3ba0 129 * next time it's requested.
6a488035 130 *
6a488035 131 *
da6b46f4 132 * @param bool|string $name pseudoconstant to be flushed
6a488035 133 */
3f3a3ba0 134 public static function flush($name = 'cache') {
94880218 135 if (isset(self::$$name)) {
fa56270d 136 self::$$name = NULL;
353ffa53 137 }
6a488035 138 }
96025800 139
6a488035 140}