From c2a21a42cae7613c169942f9341d0a6b74cba073 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 10 Apr 2023 12:31:49 +0200 Subject: [PATCH] implemented massive edition of safe operation mode --- .../godmode/massive/massive_edit_agents.php | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index 1cb20e421a..44f61be9a7 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -285,10 +285,28 @@ if ($update_agents) { $result = []; foreach ($id_agents as $id_agent) { if (is_metaconsole() === true) { + $array_id = explode('|', $id_agent); try { $node = new Node((int) $array_id[0]); $node->connect(); + + $id_agent = (int) $array_id[1]; + + // Get the id_agente_modulo to update the 'safe_operation_mode' field. + if (isset($values['safe_mode_module']) === true + && ($values['safe_mode_module'] != '0') + ) { + $id_module_safe[$id_agent] = db_get_value_filter( + 'id_agente_modulo', + 'tagente_modulo', + [ + 'id_agente' => $id_agent, + 'nombre' => $values['safe_mode_module'], + ] + ); + } + $result[$id_agent] = edit_massive_agent( (int) $array_id[1], $values, @@ -477,11 +495,7 @@ function edit_massive_agent( $agent = new Agent($id_agent); $disabled_old = $agent->disabled(); - foreach ($values as $key => $value) { - $agent->{$key}($value); - } - - if (is_metaconsole() === false) { + if (empty($id_module_safe) === false) { // Get the id_agent_module for this agent to update the 'safe_operation_mode' field. if (isset($values['safe_mode_module']) === true && ($values['safe_mode_module'] != '0') @@ -490,6 +504,10 @@ function edit_massive_agent( } } + foreach ($values as $key => $value) { + $agent->{$key}($value); + } + $result['db'] = $agent->save(); if (is_metaconsole() === false) {