advanced search: ExternalFieldOqlExpression Check method

- handling of special case for the attribute "id"
- clearer error message
- typo

SVN:b1312[5749]
This commit is contained in:
Bruno Da Silva
2018-04-26 15:54:34 +00:00
parent 30494756fc
commit 88ae239a56

View File

@@ -218,6 +218,7 @@ class ExternalFieldOqlExpression extends ExternalFieldExpression implements Chec
$sParentAlias = null; $sParentAlias = null;
foreach($this->m_aExpression as $i => $oFieldOqlExpression) foreach($this->m_aExpression as $i => $oFieldOqlExpression)
{ {
if (is_null($sParentAlias)) if (is_null($sParentAlias))
{ {
$oFieldOqlExpression->RefreshAlias($oModelReflection, $aAliases, $sSourceQuery); $oFieldOqlExpression->RefreshAlias($oModelReflection, $aAliases, $sSourceQuery);
@@ -229,18 +230,36 @@ class ExternalFieldOqlExpression extends ExternalFieldExpression implements Chec
$oFieldOqlExpression->Check($oModelReflection, $aAliases, $sSourceQuery); $oFieldOqlExpression->Check($oModelReflection, $aAliases, $sSourceQuery);
$sClass = $aAliases[$oFieldOqlExpression->GetParent()]; $sClass = $aAliases[$oFieldOqlExpression->GetParent()];
$sTargetClass = $oModelReflection->GetAttributeProperty($sClass, $oFieldOqlExpression->GetName(), 'targetclass');
if (is_null($sTargetClass)) $bLastIteration = ($i == (count($this->m_aExpression) - 1));
if (!$bLastIteration)
{ {
if ($i != (count($this->m_aExpression) - 1)) if ($oFieldOqlExpression->GetName() == 'id')
{ {
throw new OqlNormalizeException('Forbiden operation for attribute', $sSourceQuery, $oFieldOqlExpression->GetNameDetails(), $oModelReflection->GetFiltersList($sClass)); $sTargetClass = null;
}
} }
else else
{ {
$sTargetClass = $oModelReflection->GetAttributeProperty($sClass, $oFieldOqlExpression->GetName(), 'targetclass');
}
if (is_null($sTargetClass))
{
throw new OqlNormalizeException('Forbidden operation for attribute', $sSourceQuery, $oFieldOqlExpression->GetNameDetails(), $oModelReflection->GetFiltersList($sClass));
}
$aAliases[$sTargetClass] = $sTargetClass; $aAliases[$sTargetClass] = $sTargetClass;
$sParentAlias = $sTargetClass; $sParentAlias = $sTargetClass;
}
else
{
if ($oFieldOqlExpression->GetName() != 'id')
{
if (!$oModelReflection->IsValidAttCode($sClass, $oFieldOqlExpression->GetName()))
{
throw new OqlNormalizeException('Invalid attribute', $sSourceQuery, $oFieldOqlExpression->GetNameDetails(), $oModelReflection->GetFiltersList($sClass));
}
}
} }
} }
} }