From ae43f8a948fd64ead440a6b749a407e967f7b4c8 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 18 Dec 2023 16:29:56 +0100 Subject: [PATCH] fix rerors selectors pandora_enterprise#12665 --- .../godmode/reporting/graph_builder.php | 30 ++++++++++++++++--- pandora_console/include/functions_modules.php | 6 ++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 2e7b1f782e..7524b64861 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -236,17 +236,39 @@ if ($add_module === true) { $id_modules ); - $id_agent_modules = db_get_all_rows_sql( - 'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND nombre IN ('".implode("','", $id_modules)."')" + $sql = sprintf( + 'SELECT id_agente_modulo + FROM tagente_modulo + WHERE id_agente IN (%s) + AND nombre IN ("%s")', + implode(',', $id_agents), + implode('","', $id_modules) ); + $id_agent_modules = db_get_all_rows_sql($sql); + if (count($id_agent_modules) > 0 && $id_agent_modules != '') { - $order = db_get_row_sql("SELECT `field_order` from tgraph_source WHERE id_graph=$id_graph ORDER BY `field_order` DESC"); + $sql_order = sprintf( + 'SELECT `field_order` + FROM tgraph_source + WHERE id_graph=%d + ORDER BY `field_order` DESC', + $id_graph + ); + $order = db_get_row_sql($sql_order); $order = $order['field_order']; foreach ($id_agent_modules as $id_agent_module) { $order++; - $result = db_process_sql_insert('tgraph_source', ['id_graph' => $id_graph, 'id_agent_module' => $id_agent_module['id_agente_modulo'], 'weight' => $weight, 'field_order' => $order]); + $result = db_process_sql_insert( + 'tgraph_source', + [ + 'id_graph' => $id_graph, + 'id_agent_module' => $id_agent_module['id_agente_modulo'], + 'weight' => $weight, + 'field_order' => $order, + ] + ); } } else { $result = false; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index b5cf42d894..2d3b5676ec 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3857,11 +3857,11 @@ function get_modules_agents( $modules = array_reduce( $modules, - function ($carry, $item) use ($id_agents, $selection) { + function ($carry, $item) use ($id_agents, $selection, $useName) { if (count($id_agents) > 1 && (bool) $selection === true) { - $carry[$item['id_agente_modulo']] = $item['alias'].' » '.$item['nombre']; + $carry[($useName === true) ? io_safe_output($item['nombre']) : $item['id_agente_modulo']] = $item['alias'].' » '.$item['nombre']; } else { - $carry[$item['id_agente_modulo']] = $item['nombre']; + $carry[($useName === true) ? io_safe_output($item['nombre']) : $item['id_agente_modulo']] = $item['nombre']; } return $carry;