mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Advanced Search: Fix ExternalFields allowed values
SVN:trunk[5668]
This commit is contained in:
@@ -746,10 +746,30 @@ class ScalarExpression extends UnaryExpression
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
case ($oAttDef instanceof AttributeExternalField):
|
||||
try
|
||||
{
|
||||
if ($this->GetValue() == 0)
|
||||
{
|
||||
$aValue['label'] = Dict::S('UI:UndefinedObject');
|
||||
}
|
||||
else
|
||||
{
|
||||
/** @var AttributeExternalKey $oAttDef */
|
||||
$sTarget = $oAttDef->GetFinalAttDef()->GetTargetClass();
|
||||
$oObj = MetaModel::GetObject($sTarget, $this->GetValue());
|
||||
|
||||
$aValue['label'] = $oObj->Get("friendlyname");
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error($e->getMessage());
|
||||
}
|
||||
break;
|
||||
case $oAttDef->IsExternalKey():
|
||||
try
|
||||
{
|
||||
|
||||
if ($this->GetValue() == 0)
|
||||
{
|
||||
$aValue['label'] = Dict::S('UI:UndefinedObject');
|
||||
|
||||
@@ -429,10 +429,12 @@ class SearchForm
|
||||
}
|
||||
if ($oAttrDef instanceof AttributeExternalField)
|
||||
{
|
||||
// Let's propose every existing value
|
||||
$oValSetDef = new ValueSetObjects('SELECT '.$sTargetClass);
|
||||
$aAllowedValues = $oValSetDef->GetValues(array());
|
||||
return array('values' => $aAllowedValues, 'count' => count($aAllowedValues));
|
||||
$aAllowedValues = array();
|
||||
while ($oObject = $oSet->Fetch())
|
||||
{
|
||||
$aAllowedValues[$oObject->GetKey()] = $oObject->GetName();
|
||||
}
|
||||
return array('values' => $aAllowedValues, 'count' => $iCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user