mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
1270 Delete modules on cascade
This commit is contained in:
parent
e18277bc89
commit
e694d6468f
@ -2118,6 +2118,9 @@ if ($delete_module) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Before delete the main module, check and delete the childrens from the original module.
|
||||
module_check_childrens_and_delete($id_borrar_modulo);
|
||||
|
||||
// Also call base function to delete modules.
|
||||
modules_delete_agent_module($id_borrar_modulo);
|
||||
|
||||
|
@ -10157,6 +10157,8 @@ function api_set_delete_module($id, $id2, $other, $trash1)
|
||||
}
|
||||
|
||||
if (!$simulate) {
|
||||
// Before delete the main module, check and delete the childrens from the original module.
|
||||
module_check_childrens_and_delete($idAgentModule);
|
||||
$return = modules_delete_agent_module($idAgentModule);
|
||||
} else {
|
||||
$return = true;
|
||||
@ -10182,6 +10184,8 @@ function api_set_delete_module($id, $id2, $other, $trash1)
|
||||
}
|
||||
|
||||
if (!$simulate) {
|
||||
// Before delete the main module, check and delete the childrens from the original module.
|
||||
module_check_childrens_and_delete($idAgentModule);
|
||||
$return = modules_delete_agent_module($idAgentModule);
|
||||
} else {
|
||||
$return = true;
|
||||
@ -14887,6 +14891,8 @@ function api_set_delete_cluster($id, $thrash1, $thrast2, $thrash3)
|
||||
|
||||
foreach ($tcluster_modules_delete_get as $key => $value) {
|
||||
$tcluster_modules_delete_get_values[] = $value['id_agente_modulo'];
|
||||
// Before delete the main module, check and delete the childrens from the original module.
|
||||
module_check_childrens_and_delete($value['id_agente_modulo']);
|
||||
}
|
||||
|
||||
$tcluster_modules_delete = modules_delete_agent_module($tcluster_modules_delete_get_values);
|
||||
@ -14963,6 +14969,8 @@ function api_set_delete_cluster_item($id, $thrash1, $thrast2, $thrast3)
|
||||
}
|
||||
|
||||
$delete_module_aa_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$id);
|
||||
// Before delete the main module, check and delete the childrens from the original module.
|
||||
module_check_childrens_and_delete($delete_module_aa_get[0]['id_agente_modulo']);
|
||||
$delete_module_aa_get_result = modules_delete_agent_module($delete_module_aa_get[0]['id_agente_modulo']);
|
||||
$delete_item = db_process_sql('delete from tcluster_item where id = '.$id);
|
||||
|
||||
|
@ -3982,6 +3982,75 @@ function recursive_get_dt_from_modules_tree(&$f_modules, $modules, $deep)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the module data from a children
|
||||
*
|
||||
* @param integer $id_module Id module
|
||||
* @return array Children module data
|
||||
*/
|
||||
function get_children_module($id_module)
|
||||
{
|
||||
$children_module_data = db_get_all_rows_sql(
|
||||
'SELECT *
|
||||
FROM tagente_modulo
|
||||
WHERE parent_module_id = '.$id_module
|
||||
);
|
||||
|
||||
return $children_module_data;
|
||||
}
|
||||
|
||||
|
||||
function module_check_childrens_and_delete($id_module)
|
||||
{
|
||||
$children_data = get_children_module($id_module);
|
||||
// Check if exist have a childer
|
||||
if ($children_data) {
|
||||
// If have more than 1 children
|
||||
if (is_array($children_data)) {
|
||||
foreach ($children_data as $children_module_data) {
|
||||
if ($children_module_data['parent_module_id']) {
|
||||
// Search children and delete this module
|
||||
// Before delete, lets check if exist (Just for cases it's already deleted)
|
||||
if (modules_check_agentmodule_exists($children_module_data['parent_module_id'])) {
|
||||
modules_delete_agent_module($children_module_data['parent_module_id']);
|
||||
}
|
||||
|
||||
module_check_childrens_and_delete($children_module_data['id_agente_modulo']);
|
||||
} else {
|
||||
// If haven't children just delete
|
||||
// Before delete, lets check if exist (Just for cases it's already deleted)
|
||||
if (modules_check_agentmodule_exists($children_module_data['id_agente_modulo'])) {
|
||||
modules_delete_agent_module($children_module_data['id_agente_modulo']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If just have 1 children
|
||||
if ($children_data['parent_module_id']) {
|
||||
// Before delete, lets check if exist (Just for cases it's already deleted)
|
||||
if (modules_check_agentmodule_exists($children_data['parent_module_id'])) {
|
||||
modules_delete_agent_module($children_data['parent_module_id']);
|
||||
}
|
||||
|
||||
module_check_childrens_and_delete($children_data['id_agente_modulo']);
|
||||
} else {
|
||||
// If haven't children just delete
|
||||
// Before delete, lets check if exist (Just for cases it's already deleted)
|
||||
if (modules_check_agentmodule_exists($children_data['id_agente_modulo'])) {
|
||||
modules_delete_agent_module($children_data['id_agente_modulo']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Haven't childrens, so delete
|
||||
// Before delete, lets check if exist (Just for cases it's already deleted)
|
||||
if (modules_check_agentmodule_exists($id_module)) {
|
||||
modules_delete_agent_module($id_module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the button with the link to open realtime stats into a new window
|
||||
* Only to native (not satellite discovered) snmp modules.
|
||||
|
Loading…
x
Reference in New Issue
Block a user