From a10945d2096489a560ae78487753809e6653026f Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Thu, 4 Jul 2019 18:33:12 +0200 Subject: [PATCH] fix bug in api function that removes an agent from a policy --- pandora_console/include/functions_api.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 0569319a29..899add9ec0 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -15059,17 +15059,18 @@ function remove_agent_from_policy($id_policy, $use_agent_name, $params) if (is_metaconsole()) { if ($use_agent_name === false) { $id_node = $params[1]; - $id_agent = db_get_value_filter('id_agente', 'tmetaconsole_agent', ['id_tagente' => $params[0], 'id_tmetaconsole_setup' => $id_node]); + $id_agent = $params[0]; } else { - $id_agent = db_get_value_filter('id_agente', 'tmetaconsole_agent', ['nombre' => $params[0]]); + $id_node = db_get_value_filter('id_tmetaconsole_setup', 'tmetaconsole_agent', ['nombre' => $params[0]]); + $id_agent = db_get_value_filter('id_tagente', 'tmetaconsole_agent', ['nombre' => $params[0]]); } - $agent = db_get_row_filter('tmetaconsole_agent', ['id_agente' => $id_agent]); + $agent = db_get_row_filter('tmetaconsole_agent', ['id_tagente' => $id_agent, 'id_tmetaconsole_setup' => $id_node]); } $policy = policies_get_policy($id_policy, false, false); - $policy_agent = db_get_row_filter('tpolicy_agents', ['id_policy' => $id_policy, 'id_agent' => $id_agent]); + $policy_agent = (is_metaconsole()) ? db_get_row_filter('tpolicy_agents', ['id_policy' => $id_policy, 'id_agent' => $id_agent, 'id_node' => $id_node]) : db_get_row_filter('tpolicy_agents', ['id_policy' => $id_policy, 'id_agent' => $id_agent]); if (empty($policy)) { returnError('error_policy', __('This policy does not exist.'));