mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Magic query arguments:
- In addition to current_contact_id, the following arguments can be used in any OQL query (provided that the page running the query requires a login): current_contact->attcode and current_user->attcode - Code refactoring: magic arguments in one single place - The "Run queries" page is now taking into account those magic arguments (do not prompt the end-user with these arguments!) SVN:trunk[3912]
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// Copyright (C) 2010-2012 Combodo SARL
|
||||
// Copyright (C) 2010-2016 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
@@ -20,7 +20,7 @@
|
||||
/**
|
||||
* Tools to design OQL queries and test them
|
||||
*
|
||||
* @copyright Copyright (C) 2010-2012 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2016 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -142,12 +142,37 @@ try
|
||||
$sSyntaxError = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$aNakedMagicArguments = array();
|
||||
foreach (MetaModel::PrepareQueryArguments(array()) as $sArgName => $value)
|
||||
{
|
||||
$iPos = strpos($sArgName, '->object()');
|
||||
if ($iPos === false)
|
||||
{
|
||||
$aNakedMagicArguments[$sArgName] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$aNakedMagicArguments[substr($sArgName, 0, $iPos)] = true;
|
||||
}
|
||||
}
|
||||
if ($oFilter)
|
||||
{
|
||||
$aArgs = array();
|
||||
foreach($oFilter->GetQueryParams() as $sParam => $foo)
|
||||
{
|
||||
// Skip magic parameters
|
||||
$iPos = strpos($sArgName, '->');
|
||||
if ($iPos === false)
|
||||
{
|
||||
$sRefName = $sParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sRefName = substr($sParam, 0, $iPos);
|
||||
}
|
||||
if (array_key_exists($sRefName, $aNakedMagicArguments)) continue;
|
||||
|
||||
$value = utils::ReadParam('arg_'.$sParam, null, true, 'raw_data');
|
||||
if (!is_null($value))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user