#11495 Fix agent name in module selection

This commit is contained in:
miguel angel rasteu 2023-12-12 10:15:37 +01:00
parent fec7bf8b90
commit 77fd03d58a
2 changed files with 18 additions and 4 deletions

View File

@ -3643,7 +3643,7 @@ function select_modules_for_agent_group(
if (!$selection && $agents != null) { if (!$selection && $agents != null) {
$number_agents = count($id_agents); $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)) { if (tags_has_user_acl_tags(false)) {

View File

@ -3801,7 +3801,7 @@ function get_modules_agents(
$return = array_reduce( $return = array_reduce(
$modules[$tserver], $modules[$tserver],
function ($carry, $item) use ($tserver, $nodes) { function ($carry, $item) use ($tserver, $nodes, $selection) {
$t = []; $t = [];
foreach ($item as $k => $v) { foreach ($item as $k => $v) {
$t[$k] = $v; $t[$k] = $v;
@ -3809,7 +3809,7 @@ function get_modules_agents(
$t['id_node'] = $tserver; $t['id_node'] = $tserver;
if ($nodes[$tserver] !== null) { if ($nodes[$tserver] !== null) {
if (isset($t['alias']) === true) { if (isset($t['alias']) === true && (bool) $selection === true) {
$t['nombre'] = io_safe_output( $t['nombre'] = io_safe_output(
$nodes[$tserver]->server_name().' » '.$t['alias'].' » '.$t['nombre'] $nodes[$tserver]->server_name().' » '.$t['alias'].' » '.$t['nombre']
); );
@ -3851,9 +3851,23 @@ function get_modules_agents(
$selection, $selection,
false, false,
$useName, $useName,
false, true,
$notStringModules $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; return $modules;