From 0704ccefea24c0623cacb86be1b085126db0d402 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 23 May 2016 16:41:43 +1200 Subject: [PATCH] Revert "CRM-17342 - Case Managed Entities - Don't recreate disabled relationship types" --- CRM/Case/ManagedEntities.php | 7 ++----- CRM/Core/PseudoConstant.php | 18 +++++++----------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/CRM/Case/ManagedEntities.php b/CRM/Case/ManagedEntities.php index 7ab1bdd812..4cef93581c 100644 --- a/CRM/Case/ManagedEntities.php +++ b/CRM/Case/ManagedEntities.php @@ -106,11 +106,8 @@ class CRM_Case_ManagedEntities { public static function createManagedRelationshipTypes(CRM_Case_XMLRepository $xmlRepo, CRM_Core_ManagedEntities $me) { $result = array(); - if (!isset(Civi::$statics[__CLASS__]['reltypes'])) { - $relationshipInfo = CRM_Core_PseudoConstant::relationshipType('label', TRUE, NULL); - Civi::$statics[__CLASS__]['reltypes'] = CRM_Utils_Array::collect(CRM_Case_XMLProcessor::REL_TYPE_CNAME, $relationshipInfo); - } - $validRelTypes = Civi::$statics[__CLASS__]['reltypes']; + $p = new CRM_Case_XMLProcessor(); + $validRelTypes = $p->allRelationshipTypes(); $relTypes = $xmlRepo->getAllDeclaredRelationshipTypes(); foreach ($relTypes as $relType) { diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 41731556a4..bb7fd00d04 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -1056,16 +1056,14 @@ WHERE id = %1"; * Db column name/label. * @param bool $reset * Reset relationship types if true. - * @param bool|NULL $isActive - * Filter by is_active. NULL to disable. + * * * @return array * array reference of all relationship types. */ - public static function &relationshipType($valueColumnName = 'label', $reset = FALSE, $isActive = 1) { - $cacheKey = $valueColumnName . '::' . $isActive; - if (!CRM_Utils_Array::value($cacheKey, self::$relationshipType) || $reset) { - self::$relationshipType[$cacheKey] = array(); + public static function &relationshipType($valueColumnName = 'label', $reset = FALSE) { + if (!CRM_Utils_Array::value($valueColumnName, self::$relationshipType) || $reset) { + self::$relationshipType[$valueColumnName] = array(); //now we have name/label columns CRM-3336 $column_a_b = "{$valueColumnName}_a_b"; @@ -1074,13 +1072,11 @@ WHERE id = %1"; $relationshipTypeDAO = new CRM_Contact_DAO_RelationshipType(); $relationshipTypeDAO->selectAdd(); $relationshipTypeDAO->selectAdd("id, {$column_a_b}, {$column_b_a}, contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b"); - if ($isActive !== NULL) { - $relationshipTypeDAO->is_active = $isActive; - } + $relationshipTypeDAO->is_active = 1; $relationshipTypeDAO->find(); while ($relationshipTypeDAO->fetch()) { - self::$relationshipType[$cacheKey][$relationshipTypeDAO->id] = array( + self::$relationshipType[$valueColumnName][$relationshipTypeDAO->id] = array( 'id' => $relationshipTypeDAO->id, $column_a_b => $relationshipTypeDAO->$column_a_b, $column_b_a => $relationshipTypeDAO->$column_b_a, @@ -1092,7 +1088,7 @@ WHERE id = %1"; } } - return self::$relationshipType[$cacheKey]; + return self::$relationshipType[$valueColumnName]; } /** -- 2.25.1