test - flush pseudoconstant on case test, comments
[civicrm-core.git] / CRM / Case / PseudoConstant.php
index 5f00dbd311cdb394985a6dc483b5082f736419fa..8bade1c581dd26ed13b213c00f2e20cfdd2b1e4e 100644 (file)
@@ -74,18 +74,16 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    */
   static $activityTypeList = array();
 
-  /**
-   * case type
-   * @var array
-   * @static
-   */
-  static $caseTypePair = array();
-
   /**
    * Get all the case statues
    *
    * @access public
    *
+   * @param string $column
+   * @param bool $onlyActive
+   * @param null $condition
+   * @param bool $fresh
+   *
    * @return array - array reference of all case statues
    * @static
    */
@@ -110,6 +108,8 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    *
    * @access public
    *
+   * @param null $filter
+   *
    * @return array - array reference of all redaction rules
    * @static
    */
@@ -138,22 +138,32 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    *
    * @access public
    *
+   * @param string $column
+   * @param bool $onlyActive
+   *
    * @return array - array reference of all case type
    * @static
    */
-  public static function caseType($column = 'label', $onlyActive = TRUE, $condition = NULL) {
-    $cacheKey = "{$column}_" . (int)$onlyActive;
-    if (!$condition) {
-      $condition = 'AND filter = 0';
-    }
-    if (!isset(self::$caseType[$cacheKey])) {
-      self::$caseType[$cacheKey] = CRM_Core_OptionGroup::values('case_type',
-        FALSE, FALSE, FALSE, $condition,
-        $column, $onlyActive
-      );
+  public static function caseType($column = 'title', $onlyActive = TRUE) {
+    if ($onlyActive) {
+      $condition = " is_active = 1 ";
+    } else {
+      $condition = NULL;
     }
-
-    return self::$caseType[$cacheKey];
+    $caseType = NULL;
+    // FIXME: deprecated?
+    CRM_Core_PseudoConstant::populate(
+      $caseType,
+      'CRM_Case_DAO_CaseType',
+      TRUE,
+      $column,
+      '',
+      $condition,
+      'weight',
+      'id'
+    );
+
+    return $caseType;
   }
 
   /**
@@ -161,6 +171,9 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    *
    * @access public
    *
+   * @param string $column
+   * @param bool $onlyActive
+   *
    * @return array - array reference of all Encounter Medium.
    * @static
    */
@@ -184,6 +197,8 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    * @param boolean $indexName - true return activity name in array
    * key else activity id as array key.
    *
+   * @param bool $all
+   *
    * @access public
    * @static
    *
@@ -235,41 +250,6 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
     return self::$activityTypeList[$cache];
   }
 
-  /**
-   * Get the associated case type name/id, given a case Id
-   *
-   * @access public
-   *
-   * @return array - array reference of all case type name/id
-   * @static
-   */
-  public static function caseTypeName($caseId, $column = 'name') {
-    if (!$caseId) {
-      return FALSE;
-    }
-
-    if (!array_key_exists($caseId, self::$caseTypePair) || empty(self::$caseTypePair[$caseId][$column])) {
-      $caseTypes = self::caseType($column);
-      $caseTypeIds = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case',
-        $caseId,
-        'case_type_id'
-      );
-      $caseTypeId = explode(CRM_Core_DAO::VALUE_SEPARATOR,
-        trim($caseTypeIds,
-          CRM_Core_DAO::VALUE_SEPARATOR
-        )
-      );
-      $caseTypeId = $caseTypeId[0];
-
-      self::$caseTypePair[$caseId][$column] = array(
-        'id' => $caseTypeId,
-        'name' => $caseTypes[$caseTypeId],
-      );
-    }
-
-    return self::$caseTypePair[$caseId][$column];
-  }
-
   /**
    * Flush given pseudoconstant so it can be reread from db
    * next time it's requested.
@@ -277,8 +257,7 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
    * @access public
    * @static
    *
-   * @param boolean $name pseudoconstant to be flushed
-   *
+   * @param bool|string $name pseudoconstant to be flushed
    */
   public static function flush($name = 'cache') {
    if (isset(self::$$name)) {