diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 43dde74f19..baf18ab41b 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1640,13 +1640,13 @@ if (check_login()) { $children_selected = false; } else { foreach ($parent_modules as $parent) { - $child_modules = get_children_module($parent_modules, ['nombre', 'id_agente_modulo']); + $child_modules = get_children_module($parent_modules, ['nombre', 'id_agente_modulo'], true); if ((bool) $child_modules === false) { continue; } foreach ($child_modules as $child) { - $module_exist = in_array($child['id_agente_modulo'], $children_selected); + $module_exist = in_array($child['id_agente_modulo'], $parent_modules); $child_exist = in_array($child, $children_selected); if ($module_exist === false && $child_exist === false) { diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index d45b2f19ce..c1006a95e8 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3986,9 +3986,10 @@ function recursive_get_dt_from_modules_tree(&$f_modules, $modules, $deep) * Get the module data from a children * * @param integer $id_module Id module + * @param boolean $recursive Recursive children search. * @return array Children module data */ -function get_children_module($id_module, $fields=false) +function get_children_module($id_module, $fields=false, $recursion=false) { $children_module_data = db_get_all_rows_filter( 'tagente_modulo', @@ -3996,6 +3997,17 @@ function get_children_module($id_module, $fields=false) $fields ); + if ($children_module_data !== false && $recursion === true) { + foreach ($children_module_data as $child) { + $niece = get_children_module($child['id_agente_modulo'], $fields, false); + if ((bool) $niece === false) { + continue; + } else { + $children_module_data = array_merge($children_module_data, $niece); + } + } + } + return $children_module_data; }