From 77fd03d58a58d216bfa320502fb583c13aabef16 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 12 Dec 2023 10:15:37 +0100 Subject: [PATCH] #11495 Fix agent name in module selection --- pandora_console/include/functions_agents.php | 2 +- pandora_console/include/functions_modules.php | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 3f9bd48955..aa122b292f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3643,7 +3643,7 @@ function select_modules_for_agent_group( if (!$selection && $agents != null) { $number_agents = count($id_agents); - $selection_filter = "HAVING COUNT(id_agente_modulo) = $number_agents"; + $selection_filter = "GROUP BY nombre HAVING COUNT(id_agente_modulo) = $number_agents"; } if (tags_has_user_acl_tags(false)) { diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 019f92d4e1..b5cf42d894 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3801,7 +3801,7 @@ function get_modules_agents( $return = array_reduce( $modules[$tserver], - function ($carry, $item) use ($tserver, $nodes) { + function ($carry, $item) use ($tserver, $nodes, $selection) { $t = []; foreach ($item as $k => $v) { $t[$k] = $v; @@ -3809,7 +3809,7 @@ function get_modules_agents( $t['id_node'] = $tserver; if ($nodes[$tserver] !== null) { - if (isset($t['alias']) === true) { + if (isset($t['alias']) === true && (bool) $selection === true) { $t['nombre'] = io_safe_output( $nodes[$tserver]->server_name().' » '.$t['alias'].' » '.$t['nombre'] ); @@ -3851,9 +3851,23 @@ function get_modules_agents( $selection, false, $useName, - false, + true, $notStringModules ); + + $modules = array_reduce( + $modules, + function ($carry, $item) use ($id_agents, $selection) { + if (count($id_agents) > 1 && (bool) $selection === true) { + $carry[$item['id_agente_modulo']] = $item['alias'].' » '.$item['nombre']; + } else { + $carry[$item['id_agente_modulo']] = $item['nombre']; + } + + return $carry; + }, + [] + ); } return $modules;