From fc0db16d5e060c31b4d8b2138da733b63cc5d9a7 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 28 Aug 2017 15:47:16 +0200 Subject: [PATCH] Fixed "any" filter with selects unknown and not init modules in massive delete operation --- .../massive/massive_delete_modules.php | 24 +++++++++++++++---- .../godmode/massive/massive_edit_modules.php | 22 +++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index ceb55af00a..8d3260df3d 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -48,7 +48,7 @@ if (is_ajax ()) { return; } -function process_manage_delete ($module_name, $id_agents) { +function process_manage_delete ($module_name, $id_agents, $module_status = 'all') { global $config; @@ -217,6 +217,20 @@ function process_manage_delete ($module_name, $id_agents) { } } + if (($module_status == 'unknown') && ($module_name[0] == "0") && (is_array($module_name)) && (count($module_name) == 1)) { + $modules_to_delete = array(); + foreach ($modules as $mod_id) { + $mod_status = (int)db_get_value_filter ('estado', 'tagente_estado', array('id_agente_modulo' => $mod_id)); + + // Unknown, not init and no data modules + if ($mod_status == 3 || $mod_status == 4 || $mod_status == 5) { + $modules_to_delete[$mod_id] = $mod_id; + } + } + + $modules = $modules_to_delete; + } + $count_deleted_modules = count($modules); if ($config['dbtype'] == "oracle") { $success = db_process_sql(sprintf("DELETE FROM tagente_modulo WHERE id_agente_modulo IN (%s)", implode(",", $modules))); @@ -251,6 +265,7 @@ $agents_id = get_parameter('id_agents'); $modules_select = get_parameter('module'); $selection_mode = get_parameter('selection_mode', 'modules'); $recursion = get_parameter('recursion'); +$modules_selection_mode = get_parameter('modules_selection_mode'); if ($delete) { switch ($selection_mode) { @@ -299,7 +314,7 @@ if ($delete) { $module_name = array(); } foreach ($module_name as $mod_name) { - $result = process_manage_delete ($mod_name['nombre'], $id_agent['id_agente']); + $result = process_manage_delete ($mod_name['nombre'], $id_agent['id_agente'], $modules_selection_mode); $count ++; $success += (int)$result; } @@ -319,7 +334,7 @@ if ($delete) { $module_name = array(); } else { - $result = process_manage_delete (array(0 => 0), $id_agent); + $result = process_manage_delete (array(0 => 0), $id_agent, $modules_selection_mode); } $success += (int)$result; } @@ -330,7 +345,8 @@ if ($delete) { } if (!$force) { - $result = process_manage_delete ($modules_, $agents_); + $result = false; + $result = process_manage_delete ($modules_, $agents_, $modules_selection_mode); } if ($result) { diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index f26c1a0c0a..7e2db21c3c 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -40,6 +40,7 @@ $agents_id = get_parameter('id_agents'); $modules_select = get_parameter('module'); $selection_mode = get_parameter('selection_mode', 'modules'); $recursion = get_parameter('recursion'); +$modules_selection_mode = get_parameter('modules_selection_mode'); $update = (bool) get_parameter_post ('update'); @@ -105,7 +106,7 @@ if ($update) { $module_name = array(); foreach ($module_name as $mod_name) { - $result = process_manage_edit($mod_name['nombre'], $id_agent); + $result = process_manage_edit($mod_name['nombre'], $id_agent, $modules_selection_mode); $count++; $success += (int)$result; } @@ -127,7 +128,7 @@ if ($update) { $module_name = array(); foreach($module_name as $mod_name) { - $result = process_manage_edit($mod_name['nombre'], $id_agent); + $result = process_manage_edit($mod_name['nombre'], $id_agent, $modules_selection_mode); $count++; $success += (int)$result; } @@ -146,7 +147,7 @@ if ($update) { foreach ($modules_ as $module_) { - $result = process_manage_edit ($module_, $agent_); + $result = process_manage_edit ($module_, $agent_, $modules_selection_mode); $count++; $success += (int)$result; @@ -1112,7 +1113,7 @@ function disabled_status () { /* ]]> */ $mod_id)); + + // Unknown, not init and no data modules + if ($mod_status == 3 || $mod_status == 4 || $mod_status == 5) { + $modules_to_delete[$mod_id] = $mod_id; + } + } + $modules = $modules_to_delete; + } foreach ($modules as $module) { $result = modules_update_agent_module(