Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion core/ormlinkset.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -309,6 +316,7 @@ public function Fetch()
return $ret;
}


/**
* Return the current element
*
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
9 changes: 9 additions & 0 deletions sources/Core/AttributeDefinition/AttributeLinkedSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*
Expand All @@ -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(
Expand Down Expand Up @@ -143,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
Expand Down