';
$sFilterValue = '';
$sFilterValue = utils::ReadParam($sFilterCode, '');
@@ -1607,5 +1608,15 @@ EOF
}
return $aResult;
}
+
+ /**
+ * Maps the given context parameter name to the appropriate filter/search code for this class
+ * @param string $sContextParam Name of the context parameter, i.e. 'org_id'
+ * @return string Filter code, i.e. 'customer_id'
+ */
+ public static function MapContextParam($sContextParam)
+ {
+ return $sContextParam;
+ }
}
?>
diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php
index 82cadaac6..91467bd67 100644
--- a/application/displayblock.class.inc.php
+++ b/application/displayblock.class.inc.php
@@ -320,17 +320,29 @@ class DisplayBlock
}
if ($this->m_sStyle != 'links')
{
- $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
+ $oAppContext = new ApplicationContext();
+ $sClass = $this->m_oFilter->GetClass();
+ $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($sClass));
+ foreach($oAppContext->GetNames() as $sContextParam)
+ {
+ eval("\$sParamCode = $sClass::MapContextParam('$sFilterCode');"); //Map context parameter to the value/filter code depending on the class
+ }
foreach($aFilterCodes as $sFilterCode)
{
$sExternalFilterValue = utils::ReadParam($sFilterCode, '');
if (isset($aExtraParams[$sFilterCode]))
{
- $this->m_oFilter->AddCondition($sFilterCode, trim($aExtraParams[$sFilterCode])); // Use the default 'loose' operator
+ $condition = $aExtraParams[$sFilterCode];
}
else if ($bDoSearch && $sExternalFilterValue != "")
{
- $this->m_oFilter->AddCondition($sFilterCode, trim($sExternalFilterValue)); // Use the default 'loose' operator
+ // Search takes precedence over context params...
+ $condition = trim($sExternalFilterValue);
+ }
+
+ if (!is_null($condition))
+ {
+ $this->m_oFilter->AddCondition($sFilterCode, $condition); // Use the default 'loose' operator
}
}
}
@@ -582,7 +594,7 @@ class DisplayBlock
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
foreach($oAppContext->GetNames() as $sFilterCode)
{
- $sContextParamValue = trim(utils::ReadParam($sFilterCode, null));
+ $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null);
if (!is_null($sContextParamValue) && ! empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode))
{
$this->m_oFilter->AddCondition($sFilterCode, $sContextParamValue); // Use the default 'loose' operator
@@ -596,7 +608,7 @@ class DisplayBlock
$this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
}
$iCount = $this->m_oSet->Count();
- $sHyperlink = '../pages/UI.php?operation=search&filter='.$this->m_oFilter->serialize();
+ $sHyperlink = '../pages/UI.php?operation=search&'.$oAppContext->GetForLink().'&filter='.$this->m_oFilter->serialize();
$sHtml .= '';
$sHtml .= MetaModel::GetClassIcon($sClass, true, 'float;left;margin-right:10px;');
$sHtml .= MetaModel::GetName($sClass).': '.$iCount.'
';
@@ -624,7 +636,7 @@ class DisplayBlock
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
foreach($oAppContext->GetNames() as $sFilterCode)
{
- $sContextParamValue = trim(utils::ReadParam($sFilterCode, null));
+ $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null);
if (!is_null($sContextParamValue) && ! empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode))
{
$this->m_oFilter->AddCondition($sFilterCode, $sContextParamValue); // Use the default 'loose' operator
@@ -657,7 +669,7 @@ class DisplayBlock
}
else
{
- $sHyperlink = '../pages/UI.php?operation=search&filter='.$oFilter->serialize();
+ $sHyperlink = '../pages/UI.php?operation=search&'.$oAppContext->GetForLink().'&filter='.$oFilter->serialize();
$aCounts[$sStateValue] = "{$aCounts[$sStateValue]}";
}
}
@@ -666,7 +678,7 @@ class DisplayBlock
$sHtml .= '| '.implode(' | ', $aCounts).' |
';
// Title & summary
$iCount = $this->m_oSet->Count();
- $sHyperlink = '../pages/UI.php?operation=search&filter='.$this->m_oFilter->serialize();
+ $sHyperlink = '../pages/UI.php?operation=search&'.$oAppContext->GetForLink().'&filter='.$this->m_oFilter->serialize();
$sHtml .= ''.Dict::S(str_replace('_', ':', $sTitle)).'
';
$sHtml .= ''.Dict::Format(str_replace('_', ':', $sLabel), $iCount).'';
break;
diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php
index 2255eed43..3ab63d2ea 100644
--- a/application/itopwebpage.class.inc.php
+++ b/application/itopwebpage.class.inc.php
@@ -32,12 +32,12 @@ require_once("../application/user.preferences.class.inc.php");
class iTopWebPage extends NiceWebPage
{
private $m_sMenu;
- private $m_currentOrganization;
+// private $m_currentOrganization;
private $m_aTabs;
private $m_sCurrentTabContainer;
private $m_sCurrentTab;
- public function __construct($sTitle, $currentOrganization)
+ public function __construct($sTitle)
{
parent::__construct($sTitle);
$this->m_sCurrentTabContainer = '';
@@ -46,7 +46,7 @@ class iTopWebPage extends NiceWebPage
$this->m_sMenu = "";
$oAppContext = new ApplicationContext();
$sExtraParams = $oAppContext->GetForLink();
- $this->m_currentOrganization = $currentOrganization;
+// $this->m_currentOrganization = $currentOrganization;
$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->add_linked_stylesheet("../css/jquery.treeview.css");
@@ -478,15 +478,17 @@ EOF
break;
default:
+ $oAppContext = new ApplicationContext();
+ $iCurrentOrganization = $oAppContext->GetCurrentValue('org_id');
$sHtml = '';
- $sHtml .= '
';
@@ -511,10 +513,9 @@ EOF
{
// Display the menu
$oAppContext = new ApplicationContext();
- $iActiveNodeId = ApplicationMenu::GetActiveNodeId();
$iAccordionIndex = 0;
- ApplicationMenu::DisplayMenu($this, $oAppContext->GetAsHash(), $iActiveNodeId);
+ ApplicationMenu::DisplayMenu($this, $oAppContext->GetAsHash());
}
/**
diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php
index 012013c34..652a3b75d 100644
--- a/application/menunode.class.inc.php
+++ b/application/menunode.class.inc.php
@@ -218,7 +218,8 @@ class ApplicationMenu
*/
static public function GetActiveNodeId()
{
- $iMenuIndex = utils::ReadParam('menu', -1);
+ $oAppContext = new ApplicationContext();
+ $iMenuIndex = $oAppContext->GetCurrentValue('menu', -1);
if ($iMenuIndex == -1)
{
@@ -319,7 +320,7 @@ abstract class MenuNode
public function GetHyperlink($aExtraParams)
{
- $aExtraParams['menu'] = $this->GetIndex();
+ $aExtraParams['c[menu]'] = $this->GetIndex();
return $this->AddParams('../pages/UI.php', $aExtraParams);
}
@@ -593,7 +594,7 @@ class WebPageMenuNode extends MenuNode
public function GetHyperlink($aExtraParams)
{
- $aExtraParams['menu'] = $this->GetIndex();
+ $aExtraParams['c[menu]'] = $this->GetIndex();
return $this->AddParams( $this->sHyperlink, $aExtraParams);
}
@@ -631,7 +632,7 @@ class NewObjectMenuNode extends MenuNode
public function GetHyperlink($aExtraParams)
{
$sHyperlink = '../pages/UI.php?operation=new&class='.$this->sClass;
- $aExtraParams['menu'] = $this->GetIndex();
+ $aExtraParams['c[menu]'] = $this->GetIndex();
return $this->AddParams($sHyperlink, $aExtraParams);
}
diff --git a/application/template.class.inc.php b/application/template.class.inc.php
index 52388acbc..dca6d7a29 100644
--- a/application/template.class.inc.php
+++ b/application/template.class.inc.php
@@ -240,7 +240,7 @@ class DisplayTemplate
';
- $oPage = new iTopWebPage('Unit Test', 3);
+ $oPage = new iTopWebPage('Unit Test');
//$oPage->add("Template content: ".htmlentities($sTemplate)."
\n");
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, array('class'=>'Network device','pkey'=> 271, 'name' => 'deliversw01.mecanorama.fr', 'org_id' => 3));
diff --git a/js/utils.js b/js/utils.js
index 58f48e618..ca7661a4c 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -99,7 +99,7 @@ function UpdateFileName(id, sNewFileName)
/**
* Reload a search form for the specified class
*/
-function ReloadSearchForm(divId, sClassName, sBaseClass)
+function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
{
var oDiv = $('#'+divId);
oDiv.block();
@@ -112,7 +112,7 @@ function ReloadSearchForm(divId, sClassName, sBaseClass)
aSubmit = oFormEvents.submit;
}
- $.post('ajax.render.php',
+ $.post('ajax.render.php?'+sContext,
{ operation: 'search_form', className: sClassName, baseClass: sBaseClass, currentId: divId },
function(data) {
oDiv.empty();
diff --git a/pages/UI.php b/pages/UI.php
index 4285b17cc..d0eb13e7b 100644
--- a/pages/UI.php
+++ b/pages/UI.php
@@ -501,7 +501,6 @@ try
require_once('../application/startup.inc.php');
$oAppContext = new ApplicationContext();
- $currentOrganization = utils::ReadParam('org_id', '');
$operation = utils::ReadParam('operation', '');
$oKPI = new ExecutionKPI();
@@ -511,7 +510,7 @@ try
$oKPI->ComputeAndReport('User login');
- $oP = new iTopWebPage(Dict::S('UI:WelcomeToITop'), $currentOrganization);
+ $oP = new iTopWebPage(Dict::S('UI:WelcomeToITop'));
switch($operation)
{
@@ -781,7 +780,12 @@ try
$oP->add_linked_script("../js/linkswidget.js");
$oP->add_linked_script("../js/jquery.blockUI.js");
- $aArgs = array_merge($oAppContext->GetAsHash(), utils::ReadParam('default', array()));
+ $aArgs = utils::ReadParam('default', array());
+ $aContext = $oAppContext->GetAsHash();
+ foreach( $oAppContext->GetNames() as $key)
+ {
+ $aArgs[$key] = $oAppContext->GetCurrentValue($key);
+ }
// If the specified class has subclasses, ask the user an instance of which class to create
$aSubClasses = MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL); // Including the specified class itself
@@ -818,9 +822,9 @@ try
$oP->add("\n");
$aDefaults = utils::ReadParam('default', array());
$aContext = $oAppContext->GetAsHash();
- foreach($aContext as $key => $value)
+ foreach( $oAppContext->GetNames() as $key)
{
- $aDefaults[$key] = $value;
+ $aDefaults[$key] = $oAppContext->GetCurrentValue($key);
}
// Set all the default values in an object and clone this "default" object
$oObjToClone = MetaModel::NewObject($sRealClass);
diff --git a/pages/UniversalSearch.php b/pages/UniversalSearch.php
index 3c09a2bd0..2cd24d5d5 100644
--- a/pages/UniversalSearch.php
+++ b/pages/UniversalSearch.php
@@ -33,10 +33,8 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
$oAppContext = new ApplicationContext();
-$iActiveNodeId = utils::ReadParam('menu', -1);
-$currentOrganization = utils::ReadParam('org_id', '');
-$oP = new iTopWebPage(Dict::S('UI:UniversalSearchTitle'), $currentOrganization);
+$oP = new iTopWebPage(Dict::S('UI:UniversalSearchTitle'));
// From now on the context is limited to the the selected organization ??
diff --git a/pages/audit.php b/pages/audit.php
index 28310122f..48b951837 100644
--- a/pages/audit.php
+++ b/pages/audit.php
@@ -28,14 +28,13 @@ try
require_once('../application/itopwebpage.class.inc.php');
require_once('../application/startup.inc.php');
- $currentOrganization = utils::ReadParam('org_id', '');
$operation = utils::ReadParam('operation', '');
$oAppContext = new ApplicationContext();
require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
- $oP = new iTopWebPage(Dict::S('UI:Audit:Title'), $currentOrganization);
+ $oP = new iTopWebPage(Dict::S('UI:Audit:Title'));
function GetRuleResultSet($iRuleId, $oDefinitionFilter)
{
diff --git a/pages/csvimport.php b/pages/csvimport.php
index 28e3fc89a..c924cb32d 100644
--- a/pages/csvimport.php
+++ b/pages/csvimport.php
@@ -35,10 +35,9 @@ try
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oAppContext = new ApplicationContext();
- $currentOrganization = utils::ReadParam('org_id', 1);
$iStep = utils::ReadParam('step', 1);
- $oPage = new iTopWebPage(Dict::S('UI:Title:BulkImport'), $currentOrganization);
+ $oPage = new iTopWebPage(Dict::S('UI:Title:BulkImport'));
/**
* Helper function to build a select from the list of valid classes for a given action
diff --git a/pages/navigator.php b/pages/navigator.php
index 0d543a9db..6225384b0 100755
--- a/pages/navigator.php
+++ b/pages/navigator.php
@@ -27,10 +27,8 @@ LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$sOperation = utils::ReadParam('operation', 'menu');
$oAppContext = new ApplicationContext();
-$iActiveNodeId = utils::ReadParam('menu', -1);
-$currentOrganization = utils::ReadParam('org_id', '');
-$oP = new iTopWebPage("iTop - Navigator", $currentOrganization);
+$oP = new iTopWebPage("iTop - Navigator");
// Main program
$sClass = utils::ReadParam('class', '');
diff --git a/pages/run_query.php b/pages/run_query.php
index 4bea654a3..dba1e7d88 100644
--- a/pages/run_query.php
+++ b/pages/run_query.php
@@ -91,10 +91,8 @@ function ShowExamples($oP, $sExpression)
$sOperation = utils::ReadParam('operation', 'menu');
$oAppContext = new ApplicationContext();
-$iActiveNodeId = utils::ReadParam('menu', -1);
-$currentOrganization = utils::ReadParam('org_id', '');
-$oP = new iTopWebPage(Dict::S('UI:RunQuery:Title'), $currentOrganization);
+$oP = new iTopWebPage(Dict::S('UI:RunQuery:Title'));
// Main program
$sExpression = utils::ReadParam('expression', '');
diff --git a/pages/schema.php b/pages/schema.php
index 94af2cf00..fb3367bb0 100644
--- a/pages/schema.php
+++ b/pages/schema.php
@@ -507,11 +507,9 @@ function DisplayRelationDetails($oPage, $sRelCode)
// Display the menu on the left
$oAppContext = new ApplicationContext();
-$iActiveNodeId = utils::ReadParam('menu', -1);
-$currentOrganization = utils::ReadParam('org_id', 1);
$operation = utils::ReadParam('operation', '');
-$oPage = new iTopWebPage(Dict::S('UI:Schema:Title'), $currentOrganization);
+$oPage = new iTopWebPage(Dict::S('UI:Schema:Title'));
$oPage->no_cache();
$operation = utils::ReadParam('operation', '');