X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FPseudoConstant.php;h=8bade1c581dd26ed13b213c00f2e20cfdd2b1e4e;hb=745b795a992ffef1077dbe99dc854d5f303a5998;hp=c07e0cfae77789309b92720481cca22a780d8297;hpb=23b24af4939c842a35f54b6f215a3a0b1c73b8e6;p=civicrm-core.git diff --git a/CRM/Case/PseudoConstant.php b/CRM/Case/PseudoConstant.php index c07e0cfae7..8bade1c581 100644 --- a/CRM/Case/PseudoConstant.php +++ b/CRM/Case/PseudoConstant.php @@ -74,31 +74,29 @@ 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 */ - public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL) { + 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])) { + if (!isset(self::$caseStatus[$cacheKey]) || $fresh) { self::$caseStatus[$cacheKey] = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, $condition, - $column, $onlyActive + $column, $onlyActive, $fresh ); } @@ -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,19 +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) { - $cacheKey = "{$column}_" . (int)$onlyActive; - if (!isset(self::$caseType[$cacheKey])) { - self::$caseType[$cacheKey] = CRM_Core_OptionGroup::values('case_type', - FALSE, FALSE, FALSE, NULL, - $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; } /** @@ -158,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 */ @@ -181,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 * @@ -232,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. @@ -274,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)) {