diff --git a/application/datatable.class.inc.php b/application/datatable.class.inc.php
index 81e749303..0080db0aa 100644
--- a/application/datatable.class.inc.php
+++ b/application/datatable.class.inc.php
@@ -40,7 +40,7 @@ class DataTable
*/
public function __construct($iListId, $oSet, $aClassAliases, $sTableId = null)
{
- $this->iListId = str_replace(array('[', ']', '-', ':'), '_', $iListId); // Make a "safe" ID for jQuery
+ $this->iListId = utils::GetSafeId($iListId); // Make a "safe" ID for jQuery
$this->oSet = $oSet;
$this->aClassAliases = $aClassAliases;
$this->sTableId = $sTableId;
diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php
index 024279d8a..ed75ab623 100644
--- a/application/menunode.class.inc.php
+++ b/application/menunode.class.inc.php
@@ -644,12 +644,13 @@ class OQLMenuNode extends MenuNode
$this->bSearch, // Search pane
true, // Search open
$oPage,
- $aExtraParams
+ array_merge($this->m_aParams, $aExtraParams)
);
}
public static function RenderOQLSearch($sOql, $sTitle, $sUsageId, $bSearchPane, $bSearchOpen, WebPage $oPage, $aExtraParams = array())
{
+ $sUsageId = utils::GetSafeId($sUsageId);
$oSearch = DBObjectSearch::FromOQL($sOql);
$sIcon = MetaModel::GetClassIcon($oSearch->GetClass());
@@ -699,7 +700,7 @@ class SearchMenuNode extends MenuNode
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
$oSearch = new DBObjectSearch($this->sClass);
- $aParams = array_merge(array('open' => true, 'table_id' => 'Menu_'.$this->GetMenuId()), $aExtraParams);
+ $aParams = array_merge(array('open' => true, 'table_id' => 'Menu_'.utils::GetSafeId($this->GetMenuId())), $aExtraParams);
$oBlock = new DisplayBlock($oSearch, 'search', false /* Asynchronous */, $aParams);
$oBlock->Display($oPage, 0);
}
diff --git a/application/ui.linkswidget.class.inc.php b/application/ui.linkswidget.class.inc.php
index 2e3e41ccc..bd906847e 100644
--- a/application/ui.linkswidget.class.inc.php
+++ b/application/ui.linkswidget.class.inc.php
@@ -120,7 +120,7 @@ class UILinksWidget
foreach($this->m_aEditableFields as $sFieldCode)
{
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.$linkObjOrId->GetKey().']';
- $sSafeId = self::MakeID($sFieldId);
+ $sSafeId = utils::GetSafeId($sFieldId);
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $linkObjOrId->Get($sFieldCode), '' /* DisplayValue */, $sSafeId, $sNameSuffix, 0, $aArgs);
$aFieldsMap[$sFieldCode] = $sSafeId;
@@ -145,7 +145,7 @@ class UILinksWidget
foreach($this->m_aEditableFields as $sFieldCode)
{
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.$linkObjOrId.']';
- $sSafeId = self::MakeID($sFieldId);
+ $sSafeId = utils::GetSafeId($sFieldId);
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $oNewLinkObj->Get($sFieldCode) /* TO DO/ call GetDefaultValue($oObject->ToArgs()) */, '' /* DisplayValue */, $sSafeId /* id */, $sNameSuffix, 0, $aArgs);
$aFieldsMap[$sFieldCode] = $sSafeId;
@@ -175,11 +175,11 @@ EOF
);
}
- $sExtKeyToMeId = self::MakeID($sPrefix.$this->m_sExtKeyToMe);
+ $sExtKeyToMeId = utils::GetSafeId($sPrefix.$this->m_sExtKeyToMe);
$aFieldsMap[$this->m_sExtKeyToMe] = $sExtKeyToMeId;
$aRow['form::checkbox'] .= "GetKey()."\">";
- $sExtKeyToRemoteId = self::MakeID($sPrefix.$this->m_sExtKeyToRemote);
+ $sExtKeyToRemoteId = utils::GetSafeId($sPrefix.$this->m_sExtKeyToRemote);
$aFieldsMap[$this->m_sExtKeyToRemote] = $sExtKeyToRemoteId;
$aRow['form::checkbox'] .= "";
@@ -200,11 +200,6 @@ EOF
}
return $aRow;
}
-
- protected function MakeID($sName)
- {
- return str_replace(array('[', ']', '-'), '_', $sName);
- }
/**
* Display one row of the whole form
diff --git a/application/utils.inc.php b/application/utils.inc.php
index d1dcd9d3b..0a6f14739 100644
--- a/application/utils.inc.php
+++ b/application/utils.inc.php
@@ -840,6 +840,16 @@ class utils
{
return $sProposed;
}
- }
+ }
+
+ /**
+ * Some characters cause troubles with jQuery when used inside DOM IDs, so let's replace them by the safe _ (underscore)
+ * @param string $sId The ID to sanitize
+ * @return string The sanitized ID
+ */
+ static public function GetSafeId($sId)
+ {
+ return str_replace(array(':', '[', ']', '+', '-'), '_', $sId);
+ }
}
?>
\ No newline at end of file