mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
Advanced Search: Support of undefined values for enum and external keys
SVN:b1162[5495]
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Combodo\iTop\Application\Search\CriterionConversion;
|
||||
|
||||
use AttributeDateTime;
|
||||
use AttributeDefinition;
|
||||
use AttributeExternalKey;
|
||||
use Combodo\iTop\Application\Search\AjaxSearchException;
|
||||
use Combodo\iTop\Application\Search\CriterionConversionAbstract;
|
||||
use Combodo\iTop\Application\Search\SearchForm;
|
||||
@@ -149,6 +150,8 @@ class CriterionToOQL extends CriterionConversionAbstract
|
||||
return "1";
|
||||
}
|
||||
|
||||
$bFilterOnUndefined = false;
|
||||
$sFilterOnUndefined = '';
|
||||
try
|
||||
{
|
||||
$aAttributeDefs = \MetaModel::ListAttributeDefs($sClass);
|
||||
@@ -182,6 +185,25 @@ class CriterionToOQL extends CriterionConversionAbstract
|
||||
}
|
||||
}
|
||||
}
|
||||
// search for "undefined"
|
||||
for ($i = 0; $i < count($aValues); $i++)
|
||||
{
|
||||
$aValue = $aValues[$i];
|
||||
if (isset($aValue['value']) && ($aValue['value'] === 'null'))
|
||||
{
|
||||
if ($oAttDef instanceof AttributeExternalKey)
|
||||
{
|
||||
$sFilterOnUndefined = "({$sRef} = 0)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sFilterOnUndefined = "ISNULL({$sRef})";
|
||||
}
|
||||
$bFilterOnUndefined = true;
|
||||
unset($aValues[$i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\CoreException $e)
|
||||
@@ -195,6 +217,21 @@ class CriterionToOQL extends CriterionConversionAbstract
|
||||
}
|
||||
$sInList = implode("','", $aInValues);
|
||||
|
||||
if ($bFilterOnUndefined)
|
||||
{
|
||||
if (count($aValues) === 0)
|
||||
{
|
||||
return "{$sFilterOnUndefined}";
|
||||
}
|
||||
|
||||
if (count($aInValues) == 1)
|
||||
{
|
||||
return "(({$sRef} = '$sInList') OR {$sFilterOnUndefined})";
|
||||
}
|
||||
|
||||
return "({$sRef} IN ('$sInList') OR {$sFilterOnUndefined})";
|
||||
}
|
||||
|
||||
if (count($aInValues) == 1)
|
||||
{
|
||||
return "({$sRef} = '$sInList')";
|
||||
|
||||
Reference in New Issue
Block a user