diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9d689dd52c..a510d6f77f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2012-03-08 Juan Manuel Ramon + + * godmode/agentes/module_manager.php + godmode/agentes/configurar_agente.php: Modification in order to + delete synthetics modules or synth module components when a synth + module is deleted. + + Fixes: #3496210 + 2012-03-08 Miguel de Dios * include/javascript/jquery-1.7.1.js, diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index e93e52d320..8db3bc7707 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -979,6 +979,37 @@ if ($delete_module) { // DELETE agent module ! if ($result === false) $error++; + // Trick to detect if we are deleting a synthetic module (avg or arithmetic) + // If result is empty then module doesn't have this type of submodules + $ops_json = enterprise_hook('modules_get_synthetic_operations', array($id_borrar_modulo)); + $result_ops_synthetic = json_decode($ops_json); + if (!empty($result_ops_synthetic)){ + $result = enterprise_hook('modules_delete_synthetic_operations', array($id_borrar_modulo)); + if ($result === false) + $error++; + } // Trick to detect if we are deleting components of synthetics modules (avg or arithmetic) + else{ + $result_components = enterprise_hook('modules_get_synthetic_components', array($id_borrar_modulo)); + $count_components = 1; + if (!empty($result_components)){ + // Get number of components pending to delete to know when it's needed to update orders + $num_components = count($result_components); + $last_target_module = 0; + foreach ($result_components as $id_target_module){ + // Detects change of component or last component to update orders + if (($count_components == $num_components) or ($last_target_module != $id_target_module)) + $update_orders = true; + else + $update_orders = false; + $result = enterprise_hook('modules_delete_synthetic_operations', array($id_target_module, $id_borrar_modulo, $update_orders)); + + if ($result === false) + $error++; + $count_components++; + $last_target_module = $id_target_module; + } + } + } //Check for errors if ($error != 0) { diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 820da246f5..a8e34c4c6a 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -142,6 +142,39 @@ if ($multiple_delete) { break; } + + // Trick to detect if we are deleting a synthetic module (avg or arithmetic) + // If result is empty then module doesn't have this type of submodules + $ops_json = enterprise_hook('modules_get_synthetic_operations', array($id_agent_module_del)); + $result_ops_synthetic = json_decode($ops_json); + if (!empty($result_ops_synthetic)){ + $result = enterprise_hook('modules_delete_synthetic_operations', array($id_agent_module_del)); + if ($result === false) + $error++; + } // Trick to detect if we are deleting components of synthetics modules (avg or arithmetic) + else{ + $result_components = enterprise_hook('modules_get_synthetic_components', array($id_agent_module_del)); + $count_components = 1; + if (!empty($result_components)){ + // Get number of components pending to delete to know when it's needed to update orders + $num_components = count($result_components); + $last_target_module = 0; + foreach ($result_components as $id_target_module){ + // Detects change of component or last component to update orders + if (($count_components == $num_components) or ($last_target_module != $id_target_module)) + $update_orders = true; + else + $update_orders = false; + $result = enterprise_hook('modules_delete_synthetic_operations', array($id_target_module, $id_agent_module_del, $update_orders)); + if ($result === false) + $error++; + $count_components++; + $last_target_module = $id_target_module; + } + } + } + + //Check for errors if ($error != 0) { db_process_sql_rollback ();