mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
Advanced Search: Fix missing query internal params
SVN:trunk[5762]
This commit is contained in:
@@ -44,7 +44,15 @@ abstract class Expression
|
|||||||
*/
|
*/
|
||||||
abstract public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true);
|
abstract public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true);
|
||||||
|
|
||||||
// recursive rendering (aArgs used as input by default, or used as output if bRetrofitParams set to True
|
/**
|
||||||
|
* recursive rendering
|
||||||
|
*
|
||||||
|
* @param array $aArgs used as input by default, or used as output if bRetrofitParams set to True
|
||||||
|
* @param bool $bRetrofitParams
|
||||||
|
*
|
||||||
|
* @return array|string
|
||||||
|
* @throws \MissingQueryArgument
|
||||||
|
*/
|
||||||
abstract public function Render(&$aArgs = null, $bRetrofitParams = false);
|
abstract public function Render(&$aArgs = null, $bRetrofitParams = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1259,6 +1267,14 @@ class VariableExpression extends UnaryExpression
|
|||||||
}
|
}
|
||||||
|
|
||||||
// recursive rendering
|
// recursive rendering
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param null $aArgs
|
||||||
|
* @param bool $bRetrofitParams
|
||||||
|
*
|
||||||
|
* @return array|string
|
||||||
|
* @throws \MissingQueryArgument
|
||||||
|
*/
|
||||||
public function Render(&$aArgs = null, $bRetrofitParams = false)
|
public function Render(&$aArgs = null, $bRetrofitParams = false)
|
||||||
{
|
{
|
||||||
if (is_null($aArgs))
|
if (is_null($aArgs))
|
||||||
|
|||||||
@@ -167,10 +167,10 @@ class CriterionToSearchForm extends CriterionConversionAbstract
|
|||||||
{
|
{
|
||||||
if (!is_null($aPrevCriterion))
|
if (!is_null($aPrevCriterion))
|
||||||
{
|
{
|
||||||
if (array_key_exists('ref', $aPrevCriterion))
|
if (array_key_exists('ref', $aPrevCriterion) && array_key_exists('widget', $aPrevCriterion))
|
||||||
{
|
{
|
||||||
// If previous has ref, the current has ref as the array is sorted with all without ref first
|
// If previous has ref, the current has ref as the array is sorted with all without ref first
|
||||||
if (strcmp($aPrevCriterion['ref'], $aCurrCriterion['ref']) == 0)
|
if (($aPrevCriterion['ref'] == $aCurrCriterion['ref']) && ($aPrevCriterion['widget'] == $aCurrCriterion['widget']))
|
||||||
{
|
{
|
||||||
// Same attribute, try to merge
|
// Same attribute, try to merge
|
||||||
if (array_key_exists('widget', $aCurrCriterion))
|
if (array_key_exists('widget', $aCurrCriterion))
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ use Expression;
|
|||||||
use FieldExpression;
|
use FieldExpression;
|
||||||
use IssueLog;
|
use IssueLog;
|
||||||
use MetaModel;
|
use MetaModel;
|
||||||
|
use MissingQueryArgument;
|
||||||
use TrueExpression;
|
use TrueExpression;
|
||||||
use utils;
|
use utils;
|
||||||
use WebPage;
|
use WebPage;
|
||||||
@@ -468,6 +469,7 @@ class SearchForm
|
|||||||
* @param bool $bIsRemovable
|
* @param bool $bIsRemovable
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \MissingQueryArgument
|
||||||
*/
|
*/
|
||||||
public function GetCriterion($oSearch, $aFields, $aArgs = array(), $bIsRemovable = true)
|
public function GetCriterion($oSearch, $aFields, $aArgs = array(), $bIsRemovable = true)
|
||||||
{
|
{
|
||||||
@@ -478,12 +480,20 @@ class SearchForm
|
|||||||
{
|
{
|
||||||
$oExpression = $oSearch->GetCriteria();
|
$oExpression = $oSearch->GetCriteria();
|
||||||
|
|
||||||
|
$aArgs = MetaModel::PrepareQueryArguments($aArgs, $oSearch->GetInternalParams());
|
||||||
|
|
||||||
if (!empty($aArgs))
|
if (!empty($aArgs))
|
||||||
{
|
{
|
||||||
$aArgs = MetaModel::PrepareQueryArguments($aArgs);
|
try
|
||||||
|
{
|
||||||
$sOQL = $oExpression->Render($aArgs);
|
$sOQL = $oExpression->Render($aArgs);
|
||||||
$oExpression = Expression::FromOQL($sOQL);
|
$oExpression = Expression::FromOQL($sOQL);
|
||||||
|
}
|
||||||
|
catch (MissingQueryArgument $e)
|
||||||
|
{
|
||||||
|
IssueLog::Error("Search form disabled: \"".$oSearch->ToOQL()."\" Error: ".$e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$aORExpressions = Expression::Split($oExpression, 'OR');
|
$aORExpressions = Expression::Split($oExpression, 'OR');
|
||||||
|
|||||||
Reference in New Issue
Block a user