diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 2ec9e66e8..b6886169b 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -1172,16 +1172,26 @@ EOF } if (($bAutoReload) && ($this->m_sStyle != 'search')) // Search form do NOT auto-reload { - $sFilter = addslashes(str_replace('"', "'", $this->m_oFilter->serialize())); // Used either for asynchronous or auto_reload - $sExtraParams = addslashes(str_replace('"', "'", json_encode($aExtraParams))); // JSON encode, change the style of the quotes and escape them + // Used either for asynchronous or auto_reload + // does a json_encode twice to get a string usable as function parameter + $sFilterBefore = $this->m_oFilter->serialize(); + $sFilter = json_encode($sFilterBefore); + $sExtraParams = json_encode(json_encode($aExtraParams)); - $oPage->add_script('if (typeof window.oAutoReloadBlock == "undefined") { - window.oAutoReloadBlock = {}; - } - if (typeof window.oAutoReloadBlock[\''.$sId.'\'] != "undefined") { - clearInterval(window.oAutoReloadBlock[\''.$sId.'\']); - } - window.oAutoReloadBlock[\''.$sId.'\'] = setInterval("ReloadBlock(\''.$sId.'\', \''.$this->m_sStyle.'\', \"'.$sFilter.'\", \"'.$sExtraParams.'\")", '.$iReloadInterval.');'); + $oPage->add_script( + <<m_sStyle}', $sFilter, $sExtraParams); +}, '$iReloadInterval'); +JS + ); } return $sHtml; diff --git a/datamodels/2.x/itop-hub-connector/launch.php b/datamodels/2.x/itop-hub-connector/launch.php index d680243f0..5e1f352d8 100644 --- a/datamodels/2.x/itop-hub-connector/launch.php +++ b/datamodels/2.x/itop-hub-connector/launch.php @@ -234,7 +234,7 @@ function MakeDataToPost($sTargetRoute) if (MetaModel::GetConfig()->Get('demo_mode')) { // Don't expose such information in demo mode - $aDataToPost = array(); + $aDataToPost = array('disabled' => true, 'reason' => 'demo_mode'); } else { @@ -466,4 +466,4 @@ catch (Exception $e) IssueLog::Error($e->getMessage()); } } - \ No newline at end of file + diff --git a/js/jquery.tablesorter.pager.js b/js/jquery.tablesorter.pager.js index 81e53c59d..b6e328c8d 100644 --- a/js/jquery.tablesorter.pager.js +++ b/js/jquery.tablesorter.pager.js @@ -285,9 +285,9 @@ function sprintf(format, etc) { } }); - $(table).find(':checkbox[name^=selectObj]').change(function() { + $(table).find(':checkbox[name^=selectObj]').on("change init-selection", function () { storeSelection(table, table.config.container, this.value, this.checked, this.disabled); - }).trigger("change"); + }).trigger("init-selection"); // don't need to trigger the very generic change event ! } else if (table.config.select_mode == 'single') { diff --git a/js/table-selectable-lines.js b/js/table-selectable-lines.js index 21f81e858..5a2d0bae2 100644 --- a/js/table-selectable-lines.js +++ b/js/table-selectable-lines.js @@ -59,8 +59,14 @@ $(document).ready(function () { $lineClickedInput.click(); }); - $(document).on('change', TABLE_SELECTOR+':has('+LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR+')', function (event) { + $(document).on('change', TABLE_SELECTOR, function (event) { var $eventTarget = $(event.target); + if (!$eventTarget.has(LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR)) + // Originally we had :has in the handler selector but performances were very bad :( + // Filtering directly in JQuery is far much quicker ! => N°2192 + { + return; + } if (!$eventTarget.is(INPUT_SELECTOR)) { return; } @@ -69,7 +75,14 @@ $(document).ready(function () { }); // check_all event is fired for tableSorter JQuery plugin - $(document).on("check_all", TABLE_SELECTOR+':has('+LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR+')', function () { + $(document).on("check_all", TABLE_SELECTOR, function (event) { + var $eventTarget = $(event.target); + if (!$eventTarget.has(LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR)) + // Originally we had :has in the handler selector but performances were very bad :( + // Filtering directly in JQuery is far much quicker ! => N°2192 + { + return; + } $(this).find("tbody>tr").addClass(SELECTED_CLASS); }); @@ -105,8 +118,9 @@ $(document).ready(function () { function updateLines($inputChanged) { var $selectedLine = $inputChanged.closest("tr"); - if ($inputChanged.is('input:radio')) { - // didn't find a proper event fired when radio is deselected... so doing this ! + // didn't find a proper event fired when radio is deselected... so doing this ! + if ($inputChanged.is('input:radio')) + { $selectedLine .closest('table') .find('tr') diff --git a/js/utils.js b/js/utils.js index 740443e19..be52a81d2 100644 --- a/js/utils.js +++ b/js/utils.js @@ -199,7 +199,7 @@ function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams) { $('#'+divId).block(); $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?style='+sStyle, - {operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams}, + {operation: 'ajax', filter: sSerializedFilter, encoding: 'serialize', extra_params: sExtraParams}, function (data) { $('#'+divId).empty(); $('#'+divId).append(data); diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 2fcafb0fb..3ca298ffc 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -743,7 +743,16 @@ try } else { - $oFilter = DBSearch::unserialize($sFilter); + try + { + $oFilter = DBSearch::unserialize($sFilter); + } + catch (CoreException $e) + { + $oPage->p("Invalid query (invalid filter) : $sFilter"); + IssueLog::Error("ajax.render operation='ajax', invalid DBSearch filter param : $sFilter"); + break; + } } $oDisplayBlock = new DisplayBlock($oFilter, $sStyle, false); $aExtraParams['display_limit'] = true;