From cf1eb4da61537ac63a52b6edbeacd0f5a3dfd4e6 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Thu, 27 Nov 2025 12:00:22 +0100 Subject: [PATCH 1/2] =?UTF-8?q?N=C2=B05221=20-=20DG=20Form:=20display=20re?= =?UTF-8?q?lated=20URs=20without=20the=20scope=20and=20its=20flag=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/ormlinkset.class.inc.php | 10 +++++++++- .../portal/src/Form/ObjectFormManager.php | 7 +++++++ .../Core/AttributeDefinition/AttributeLinkedSet.php | 8 +++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/core/ormlinkset.class.inc.php b/core/ormlinkset.class.inc.php index 56573dc517..52118fbda2 100644 --- a/core/ormlinkset.class.inc.php +++ b/core/ormlinkset.class.inc.php @@ -52,6 +52,8 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator */ protected $bHasDelta = false; + protected $bAllowAllData = false; + /** * Object from the original set, minus the removed objects * @var DBObject[] array of iObjectId => DBObject @@ -118,6 +120,11 @@ public function GetFilter() return clone $this->oOriginalSet->GetFilter(); } + public function AllowAllData(): void + { + $this->bAllowAllData = true; + } + /** * Specify the subset of attributes to load (for each class of objects) before performing the SQL query for retrieving the rows from the DB * @@ -309,6 +316,7 @@ public function Fetch() return $ret; } + /** * Return the current element * @@ -329,7 +337,7 @@ public function current() $iPreservedCount = count($this->aPreserved); if ($this->iCursor < $iPreservedCount) { $sId = key($this->aPreserved); - $oRet = MetaModel::GetObject($this->sClass, $sId); + $oRet = MetaModel::GetObject($this->sClass, $sId, true, $this->bAllowAllData); } else { $iModifiedCount = count($this->aModified); if ($this->iCursor < $iPreservedCount + $iModifiedCount) { diff --git a/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php b/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php index 8d0bfb46d5..2c77623b3c 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php @@ -365,6 +365,9 @@ public function Build() } $oAttDef = MetaModel::GetAttributeDef(get_class($this->oObject), $sAttCode); + if ($oAttDef instanceof \AttributeLinkedSet && array_key_exists($sAttCode, $this->aExtraData) && array_key_exists('ignore_scopes', $this->aExtraData[$sAttCode])) { + $oAttDef->AllowAllData(); + } /** @var Field $oField */ $oField = null; @@ -572,7 +575,11 @@ public function Build() $aLimitedAccessItemIDs = []; /** @var \ormLinkSet $oFieldOriginalSet */ + $oFieldOriginalSet = $oField->GetCurrentValue(); + if (array_key_exists($sAttCode, $this->aExtraData) && array_key_exists('ignore_scopes', $this->aExtraData[$sAttCode])) { + $oFieldOriginalSet->AllowAllData(); + } foreach ($oFieldOriginalSet as $oLink) { if ($oField->IsIndirect()) { $iRemoteKey = $oLink->Get($oAttDef->GetExtKeyToRemote()); diff --git a/sources/Core/AttributeDefinition/AttributeLinkedSet.php b/sources/Core/AttributeDefinition/AttributeLinkedSet.php index 840c9eaeaf..5ae3788fa4 100644 --- a/sources/Core/AttributeDefinition/AttributeLinkedSet.php +++ b/sources/Core/AttributeDefinition/AttributeLinkedSet.php @@ -32,6 +32,7 @@ */ class AttributeLinkedSet extends AttributeDefinition { + public $bAllowAllData = false; /** * Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329) * @@ -50,6 +51,11 @@ public function __construct($sCode, $aParams) $this->aCSSClasses[] = 'attribute-set'; } + public function AllowAllData() + { + $this->bAllowAllData = true; + } + public static function ListExpectedParams() { return array_merge( @@ -89,7 +95,7 @@ public function GetValuesDef() $oValSetDef = $this->Get("allowed_values"); if (!$oValSetDef) { // Let's propose every existing value - $oValSetDef = new ValueSetObjects('SELECT '.LinkSetModel::GetTargetClass($this)); + $oValSetDef = new ValueSetObjects('SELECT '.LinkSetModel::GetTargetClass($this), '', [], $this->bAllowAllData); } return $oValSetDef; From 80cdfc1a3493eee4891aada1886d22087d642e1e Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Fri, 28 Nov 2025 11:10:00 +0100 Subject: [PATCH 2/2] =?UTF-8?q?N=C2=B05221=20-=20DG=20Form:=20display=20re?= =?UTF-8?q?lated=20URs=20without=20the=20scope=20and=20its=20flag=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/Core/AttributeDefinition/AttributeLinkedSet.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/Core/AttributeDefinition/AttributeLinkedSet.php b/sources/Core/AttributeDefinition/AttributeLinkedSet.php index 5ae3788fa4..7085e9d598 100644 --- a/sources/Core/AttributeDefinition/AttributeLinkedSet.php +++ b/sources/Core/AttributeDefinition/AttributeLinkedSet.php @@ -95,7 +95,7 @@ public function GetValuesDef() $oValSetDef = $this->Get("allowed_values"); if (!$oValSetDef) { // Let's propose every existing value - $oValSetDef = new ValueSetObjects('SELECT '.LinkSetModel::GetTargetClass($this), '', [], $this->bAllowAllData); + $oValSetDef = new ValueSetObjects('SELECT '.LinkSetModel::GetTargetClass($this)); } return $oValSetDef; @@ -149,6 +149,9 @@ public function GetDefaultValue(DBObject $oHostObject = null) } $oLinkSearch = new DBObjectSearch($sLinkClass); + if ($this->bAllowAllData) { + $oLinkSearch->AllowAllData(true); + } $oLinkSearch->AddCondition_PointingTo($oMyselfSearch, $sExtKeyToMe); if ($this->IsIndirect()) { // Join the remote class so that the archive flag will be taken into account