Merge branch 'ent-1270-borrado-de-modulos-hijos-automatico' into 'develop'
Ent 1270 borrado de modulos hijos automatico See merge request artica/pandorafms!5340
This commit is contained in:
commit
9ad2556201
|
@ -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);
|
||||
|
||||
|
|
|
@ -247,6 +247,8 @@ if ($module_action === 'delete') {
|
|||
$print_result_msg = true;
|
||||
$count_correct_delete_modules = 0;
|
||||
foreach ($id_agent_modules_delete as $id_agent_module_del) {
|
||||
// Before delete the main module, check and delete the childrens from the original module.
|
||||
module_check_childrens_and_delete($id_agent_module_del);
|
||||
$id_grupo = (int) agents_get_agent_group($id_agente);
|
||||
$all_groups = agents_get_all_groups_agent($id_agente, $id_grupo);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3982,6 +3982,81 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find and delete the childers modules from the $id_module
|
||||
*
|
||||
* @param mixed $id_module
|
||||
* @return void
|
||||
*/
|
||||
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…
Reference in New Issue