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