From 3844a18b86bdd349c4f9f339f278391527f910e6 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 30 Oct 2019 16:40:09 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B0971=20Portal:=20Allow=20n:n=20links=20fo?= =?UTF-8?q?r=20Browse=20Brick's=20levels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Controller/BrowseBrickController.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/src/Controller/BrowseBrickController.php b/datamodels/2.x/itop-portal-base/portal/src/Controller/BrowseBrickController.php index c64473ff09..ae2d7dd1ae 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Controller/BrowseBrickController.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Controller/BrowseBrickController.php @@ -132,9 +132,25 @@ class BrowseBrickController extends BrickController if ($i < $iLoopMax) { $aRealiasingMap = array(); - $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search'] = $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->Join($aLevelsProperties[$aLevelsPropertiesKeys[$i + 1]]['search'], - DBSearch::JOIN_REFERENCED_BY, $aLevelsProperties[$aLevelsPropertiesKeys[$i + 1]]['parent_att'], - TREE_OPERATOR_EQUALS, $aRealiasingMap); + $oParentAtt = MetaModel::GetAttributeDef($aLevelsProperties[$aLevelsPropertiesKeys[$i + 1]]['search']->GetClass(), $aLevelsProperties[$aLevelsPropertiesKeys[$i + 1]]['parent_att']); + // If we work on a n:n link + if($oParentAtt instanceof \AttributeLinkedSetIndirect) + { + // Create a DBSearch from Link class + $oSubSearch = new \DBObjectSearch($oParentAtt->GetLinkedClass()); + // Join it to the bottom query + $oSubSearch = $oSubSearch->Join($aLevelsProperties[$aLevelsPropertiesKeys[$i + 1]]['search'], + DBSearch::JOIN_POINTING_TO, $oParentAtt->GetExtKeyToMe(), TREE_OPERATOR_EQUALS, $aRealiasingMap); + // Join our Link class + bottom query to the up query + $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search'] = $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search'] ->Join($oSubSearch, DBSearch::JOIN_REFERENCED_BY, + $oParentAtt->GetExtKeyToRemote(), TREE_OPERATOR_EQUALS, $aRealiasingMap); + } + else + { + $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search'] = $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->Join($aLevelsProperties[$aLevelsPropertiesKeys[$i + 1]]['search'], + DBSearch::JOIN_REFERENCED_BY, $aLevelsProperties[$aLevelsPropertiesKeys[$i + 1]]['parent_att'], + TREE_OPERATOR_EQUALS, $aRealiasingMap); + } foreach ($aLevelsPropertiesKeys as $sLevelAlias) { if (array_key_exists($sLevelAlias, $aRealiasingMap))