Merge pull request #10295 from eileenmcnaughton/tpl
[civicrm-core.git] / CRM / Case / PseudoConstant.php
index c80425acfaf5d48c7548e21433771bdeef9b60de..4fde3b50e751844df36716e1743c912e8ff3b986 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  */
 
 /**
  */
 class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
 
-  /**
-   * Case statues
-   * @var array
-   */
-  static $caseStatus = array();
-
-  /**
-   * Redaction rules
-   * @var array
-   */
-  static $redactionRule;
-
-  /**
-   * Case type
-   * @var array
-   */
-  static $caseType = array();
-
-  /**
-   * Encounter Medium
-   * @var array
-   */
-  static $encounterMedium = array();
-
   /**
    * Activity type
    * @var array
@@ -79,19 +55,15 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    *   array reference of all case statues
    */
   public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL, $fresh = FALSE) {
-    $cacheKey = "{$column}_" . (int) $onlyActive;
     if (!$condition) {
       $condition = 'AND filter = 0';
     }
 
-    if (!isset(self::$caseStatus[$cacheKey]) || $fresh) {
-      self::$caseStatus[$cacheKey] = CRM_Core_OptionGroup::values('case_status',
-        FALSE, FALSE, FALSE, $condition,
-        $column, $onlyActive, $fresh
-      );
-    }
+    return CRM_Core_OptionGroup::values('case_status',
+      FALSE, FALSE, FALSE, $condition,
+      $column, $onlyActive, $fresh
+    );
 
-    return self::$caseStatus[$cacheKey];
   }
 
   /**
@@ -104,22 +76,15 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    *   array reference of all redaction rules
    */
   public static function redactionRule($filter = NULL) {
-    // if ( ! self::$redactionRule ) {
-    self::$redactionRule = array();
-
+    $condition = NULL;
     if ($filter === 0) {
       $condition = "  AND (v.filter = 0 OR v.filter IS NULL)";
     }
     elseif ($filter === 1) {
       $condition = "  AND  v.filter = 1";
     }
-    elseif ($filter === NULL) {
-      $condition = NULL;
-    }
 
-    self::$redactionRule = CRM_Core_OptionGroup::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
-    // }
-    return self::$redactionRule;
+    return CRM_Core_OptionGroup::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
   }
 
   /**
@@ -166,15 +131,10 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    *   array reference of all Encounter Medium.
    */
   public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
-    $cacheKey = "{$column}_" . (int) $onlyActive;
-    if (!isset(self::$encounterMedium[$cacheKey])) {
-      self::$encounterMedium[$cacheKey] = CRM_Core_OptionGroup::values('encounter_medium',
-        FALSE, FALSE, FALSE, NULL,
-        $column, $onlyActive
-      );
-    }
-
-    return self::$encounterMedium[$cacheKey];
+    return CRM_Core_OptionGroup::values('encounter_medium',
+      FALSE, FALSE, FALSE, NULL,
+      $column, $onlyActive
+    );
   }
 
   /**
@@ -199,7 +159,7 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
       self::$activityTypeList[$cache] = array();
 
       $query = "
-              SELECT  v.label as label ,v.value as value, v.name as name, v.description as description
+              SELECT  v.label as label ,v.value as value, v.name as name, v.description as description, v.icon
               FROM   civicrm_option_value v,
                      civicrm_option_group g
               WHERE  v.option_group_id = g.id
@@ -231,6 +191,7 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
         $activityTypes[$index]['id'] = $dao->value;
         $activityTypes[$index]['label'] = $dao->label;
         $activityTypes[$index]['name'] = $dao->name;
+        $activityTypes[$index]['icon'] = $dao->icon;
         $activityTypes[$index]['description'] = $dao->description;
       }
       self::$activityTypeList[$cache] = $activityTypes;