From 7df7fdff7da53afc2235230b72768b4757a46c25 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 13 Dec 2023 10:32:29 +0100 Subject: [PATCH] fix msg error agent cluster pandora_enterprise#12511 --- .../godmode/agentes/modificar_agente.php | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 5ea31914c6..a7ee6bf4c0 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -958,12 +958,33 @@ if ($agents !== false) { ); if ($check_aw === true && is_management_allowed() === true) { - if ($agent['id_os'] != CLUSTER_OS_ID) { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;'; - } else { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;'; + $clusters = agents_get_agent_belongs_cluster($agent['id_agente']); + $cluster_belongs = ''; + if (empty($clusters) === false) { + $clusters = array_reduce( + $clusters, + function ($carry, $item) { + $carry[] = $item['name']; + return $carry; + } + ); + $cluster_belongs = implode(', ', $clusters); } + $msg = ''; + if ($agent['id_os'] == CLUSTER_OS_ID) { + $msg .= __('You are going to delete a cluster agent'); + $msg .= '. '; + } else if (empty($cluster_belongs) === false) { + $msg .= __('This agent belongs to the clusters'); + $msg .= ': '; + $msg .= $cluster_belongs; + $msg .= '. '; + } + + $msg .= __('Are you sure?'); + $onClickActionDeleteAgent = 'if (!confirm(\' '.$msg.'\')) return false;'; + $agentActionButtons[] = html_print_menu_button( [ 'href' => ui_get_full_url(