PseudoConstant.php 4.69 KB
Newer Older
totten's avatar
totten committed
1 2 3
<?php
/*
 +--------------------------------------------------------------------+
totten's avatar
totten committed
4
 | CiviCRM version 5                                                  |
totten's avatar
totten committed
5
 +--------------------------------------------------------------------+
Seamus Lee's avatar
Seamus Lee committed
6
 | Copyright CiviCRM LLC (c) 2004-2019                                |
totten's avatar
totten committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 +--------------------------------------------------------------------+
 | This file is a part of CiviCRM.                                    |
 |                                                                    |
 | CiviCRM is free software; you can copy, modify, and distribute it  |
 | under the terms of the GNU Affero General Public License           |
 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
 |                                                                    |
 | CiviCRM is distributed in the hope that it will be useful, but     |
 | WITHOUT ANY WARRANTY; without even the implied warranty of         |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
 | See the GNU Affero General Public License for more details.        |
 |                                                                    |
 | You should have received a copy of the GNU Affero General Public   |
 | License and the CiviCRM Licensing Exception along                  |
 | with this program; if not, contact CiviCRM LLC                     |
 | at info[AT]civicrm[DOT]org. If you have questions about the        |
 | GNU Affero General Public License or the licensing of CiviCRM,     |
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
26
 */
totten's avatar
totten committed
27 28 29 30

/**
 *
 * @package CRM
Seamus Lee's avatar
Seamus Lee committed
31
 * @copyright CiviCRM LLC (c) 2004-2019
totten's avatar
totten committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
 */

/**
 * This class holds all the Pseudo constants those
 * are specific to Campaign and Survey.
 */
class CRM_Campaign_PseudoConstant extends CRM_Core_PseudoConstant {

  /**
   * Activity types
   * @var array
   */
  private static $activityType;

  /**
   * Campaign Type
   * @var array
   */
50
  private static $campaignType = [];
totten's avatar
totten committed
51 52 53 54 55

  /**
   * Campaign Status
   * @var array
   */
56
  private static $campaignStatus = [];
totten's avatar
totten committed
57 58 59

  /**
   * Engagement Level
60
   * @var int
totten's avatar
totten committed
61 62 63 64
   */
  private static $engagementLevel;

  /**
65
   * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
totten's avatar
totten committed
66 67
   * Get all the survey activity types
   *
Eileen McNaughton's avatar
Eileen McNaughton committed
68 69
   * @param string $returnColumn
   *
70 71
   * @return array
   *   array reference of all survey activity types.
totten's avatar
totten committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
   */
  public static function &activityType($returnColumn = 'name') {
    $cacheKey = $returnColumn;
    if (!isset(self::$activityType[$cacheKey])) {
      $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
      if ($campaingCompId) {
        self::$activityType[$cacheKey] = CRM_Core_OptionGroup::values('activity_type',
          FALSE, FALSE, FALSE,
          " AND v.component_id={$campaingCompId}",
          $returnColumn
        );
      }
    }
    asort(self::$activityType[$cacheKey]);
    return self::$activityType[$cacheKey];
  }

  /**
90
   * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
totten's avatar
totten committed
91 92 93 94 95
   * Get all campaign types.
   *
   * The static array campaignType is returned
   *
   *
96 97
   * @return array
   *   array reference of all campaign types.
totten's avatar
totten committed
98 99 100 101 102 103 104 105 106 107
   */
  public static function &campaignType() {
    if (!self::$campaignType) {
      self::$campaignType = CRM_Core_OptionGroup::values('campaign_type');
    }
    asort(self::$campaignType);
    return self::$campaignType;
  }

  /**
108
   * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
totten's avatar
totten committed
109 110 111 112 113
   * Get all campaign status.
   *
   * The static array campaignStatus is returned
   *
   *
114 115
   * @return array
   *   array reference of all campaign status.
totten's avatar
totten committed
116 117 118 119 120 121 122 123 124 125
   */
  public static function &campaignStatus() {
    if (!self::$campaignStatus) {
      self::$campaignStatus = CRM_Core_OptionGroup::values('campaign_status');
    }
    asort(self::$campaignStatus);
    return self::$campaignStatus;
  }

  /**
126
   * @deprecated. Please use the buildOptions() method in the appropriate BAO object.
totten's avatar
totten committed
127 128 129 130 131
   * Get all Engagement Level.
   *
   * The static array Engagement Level is returned
   *
   *
132 133
   * @return array
   *   array reference of all Engagement Level.
totten's avatar
totten committed
134 135 136 137 138 139 140 141 142 143 144
   */
  public static function &engagementLevel() {
    if (!isset(self::$engagementLevel)) {
      self::$engagementLevel = CRM_Core_OptionGroup::values('engagement_index');
    }

    return self::$engagementLevel;
  }

  /**
   * Flush given pseudoconstant so it can be reread from db
145
   * next time it's requested.
totten's avatar
totten committed
146 147
   *
   *
Eileen McNaughton's avatar
Eileen McNaughton committed
148
   * @param bool|string $name pseudoconstant to be flushed
totten's avatar
totten committed
149
   */
150
  public static function flush($name = 'cache') {
totten's avatar
totten committed
151
    if (isset(self::$$name)) {
152
      self::$$name = NULL;
totten's avatar
totten committed
153
    }
totten's avatar
totten committed
154
  }
155

totten's avatar
totten committed
156
}