From dcdcbfad8898bd6f501d203a8b3c8e5721f57073 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 4 Apr 2022 17:40:51 +0200 Subject: [PATCH] #8786 Fixed delete address --- pandora_console/godmode/agentes/configurar_agente.php | 5 ++--- pandora_console/include/functions_agents.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 21594cde81..8e63416b97 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1065,9 +1065,9 @@ if ($update_agent) { if ($action_delete_ip) { $delete_ip = get_parameter_post('address_list'); if (empty($direccion_agente) === true) { - $direccideon_agente = agents_delete_address($id_agente, $delete_ip); + $direccion_agente = agents_delete_address($id_agente, $delete_ip, true); } else { - agents_delete_address($id_agente, $delete_ip); + $direccion_agente = agents_delete_address($id_agente, $delete_ip, true); } } @@ -1089,7 +1089,6 @@ if ($update_agent) { 'icon_path' => $icon_path, 'update_gis_data' => $update_gis_data, 'url_address' => $url_description, - 'url_address' => $url_description, 'quiet' => $quiet, 'cps' => $cps, 'safe_mode_module' => $safe_mode_module, diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index dcf134d17c..fe607f9c08 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2118,7 +2118,7 @@ function agents_add_address($id_agent, $ip_address) * @param int Agent id * @param string IP address to unassign */ -function agents_delete_address($id_agent, $ip_address) +function agents_delete_address($id_agent, $ip_address, $return=false) { global $config; @@ -2151,13 +2151,20 @@ function agents_delete_address($id_agent, $ip_address) $new_ip = reset($new_ips); } - // Change main address in agent to first one in the list + // Change main address in agent to first one in the list. db_process_sql_update( 'tagente', ['direccion' => $new_ip], ['id_agente' => $id_agent] ); + } else { + $new_ip = agents_get_address($id_agent); + if (empty($new_ip)) { + $new_ip = ''; + } + } + if ($return === true) { return $new_ip; } }