mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 15:52:24 +02:00
N°828 - GetSelectFilter issue with DBUnionSearch
This commit is contained in:
@@ -607,11 +607,30 @@ abstract class DBSearch
|
|||||||
return $sRes;
|
return $sRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract function IsDataFiltered();
|
||||||
|
protected abstract function SetDataFiltered();
|
||||||
|
|
||||||
protected function GetSQLQuery($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount, $aGroupByExpr = null, $aSelectExpr = null)
|
protected function GetSQLQuery($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount, $aGroupByExpr = null, $aSelectExpr = null)
|
||||||
{
|
{
|
||||||
$oSQLQuery = $this->GetSQLQueryStructure($aAttToLoad, $bGetCount, $aGroupByExpr, null, $aSelectExpr);
|
$oSearch = $this;
|
||||||
$oSQLQuery->SetSourceOQL($this->ToOQL());
|
if (!$this->IsAllDataAllowed() && !$this->IsDataFiltered())
|
||||||
|
{
|
||||||
|
$oVisibleObjects = UserRights::GetSelectFilter($this->GetClass(), $this->GetModifierProperties('UserRightsGetSelectFilter'));
|
||||||
|
if ($oVisibleObjects === false)
|
||||||
|
{
|
||||||
|
// Make sure this is a valid search object, saying NO for all
|
||||||
|
$oVisibleObjects = DBObjectSearch::FromEmptySet($this->GetClass());
|
||||||
|
}
|
||||||
|
if (is_object($oVisibleObjects))
|
||||||
|
{
|
||||||
|
$oVisibleObjects->AllowAllData();
|
||||||
|
$oSearch = $this->Intersect($oVisibleObjects);
|
||||||
|
/** @var DBSearch $oSearch */
|
||||||
|
$oSearch->SetDataFiltered();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$oSQLQuery = $oSearch->GetSQLQueryStructure($aAttToLoad, $bGetCount, $aGroupByExpr, null, $aSelectExpr);
|
||||||
|
$oSQLQuery->SetSourceOQL($oSearch->ToOQL());
|
||||||
|
|
||||||
// Join to an additional table, if required...
|
// Join to an additional table, if required...
|
||||||
//
|
//
|
||||||
@@ -635,6 +654,11 @@ abstract class DBSearch
|
|||||||
$aAttToLoad, $bGetCount, $aGroupByExpr = null, $aSelectedClasses = null, $aSelectExpr = null
|
$aAttToLoad, $bGetCount, $aGroupByExpr = null, $aSelectedClasses = null, $aSelectExpr = null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Expression
|
||||||
|
*/
|
||||||
|
public abstract function GetCriteria();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Cache/Trace/Log queries
|
// Cache/Trace/Log queries
|
||||||
|
|||||||
@@ -312,9 +312,9 @@ class DBUnionSearch extends DBSearch
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a condition on external keys or link sets
|
* Specify a condition on external keys or link sets
|
||||||
* @param sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
|
* @param String sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
|
||||||
* Example: infra_list->ci_id->location_id->country
|
* Example: infra_list->ci_id->location_id->country
|
||||||
* @param value The value to match (can be an array => IN(val1, val2...)
|
* @param Object value The value to match (can be an array => IN(val1, val2...)
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function AddConditionAdvanced($sAttSpec, $value)
|
public function AddConditionAdvanced($sAttSpec, $value)
|
||||||
@@ -598,4 +598,34 @@ class DBUnionSearch extends DBSearch
|
|||||||
if (self::$m_bDebugQuery) $oSQLQuery->DisplayHtml();
|
if (self::$m_bDebugQuery) $oSQLQuery->DisplayHtml();
|
||||||
return $oSQLQuery;
|
return $oSQLQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Expression
|
||||||
|
*/
|
||||||
|
public function GetCriteria()
|
||||||
|
{
|
||||||
|
return new TrueExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function IsDataFiltered()
|
||||||
|
{
|
||||||
|
$bIsAllDataFiltered = true;
|
||||||
|
foreach ($this->aSearches as $oSearch)
|
||||||
|
{
|
||||||
|
if (!$oSearch->IsDataFiltered())
|
||||||
|
{
|
||||||
|
$bIsAllDataFiltered = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $bIsAllDataFiltered;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function SetDataFiltered()
|
||||||
|
{
|
||||||
|
foreach ($this->aSearches as $oSearch)
|
||||||
|
{
|
||||||
|
$oSearch->SetDataFiltered();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user