From 50e7e5fc17d7a69a3a11719704d6c27235b4899c Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 31 Oct 2017 16:39:58 +0100 Subject: [PATCH] Added changes to sort json in ajax return --- pandora_console/include/functions_ui.php | 9 ++++++++- .../include/functions_visual_map_editor.php | 1 + pandora_console/operation/agentes/ver_agente.php | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index de10fcaf91..907ffdfbc2 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3029,7 +3029,10 @@ function ui_print_agent_autocomplete_input($parameters) { $javascript = $parameters['javascript']; } - + $get_order_json = false; + if (isset($parameters['get_order_json'])) { + $get_order_json = true; + } $javascript_is_function_select = false; //Default value if (isset($parameters['javascript_is_function_select'])) { @@ -3116,6 +3119,10 @@ function ui_print_agent_autocomplete_input($parameters) { if (' . ((int) !$metaconsole_enabled) . ') { inputs.push ("force_local_modules=1"); } + + if (' . ((int) $get_order_json) . ') { + inputs.push ("get_order_json=1"); + } if (' . ((int)$metaconsole_enabled) . ') { if ((' . ((int)$use_input_server) . ') diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 1333f5e73a..3aad97203f 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -291,6 +291,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $params['use_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true; $params['hidden_input_idagent_name'] = 'id_agent'; + $params['get_order_json'] = true; if (defined('METACONSOLE')) { $params['javascript_ajax_page'] = '../../ajax.php'; $params['disabled_javascript_on_blur_function'] = true; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 254bc4bf24..fdb1228f1c 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -702,6 +702,18 @@ if (is_ajax ()) { foreach ($agent_modules as $key => $module) { $agent_modules[$key]['nombre'] = io_safe_output($module['nombre']); } + + $get_order_json = (bool)get_parameter('get_order_json', false); + if ($get_order_json) { + $new_elements = array(); + $index = 0; + foreach ($agent_modules as $key => $module) { + $new_elements[$index]['id_agente_modulo'] = $module['id_agente_modulo']; + $new_elements[$index]['nombre'] = io_safe_output($module['nombre']); + $index++; + } + $agent_modules = $new_elements; + } echo json_encode ($agent_modules);