diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php
index e315ec3d16..f2045bf7a1 100644
--- a/pandora_console/godmode/agentes/module_manager.php
+++ b/pandora_console/godmode/agentes/module_manager.php
@@ -1283,9 +1283,13 @@ foreach ($modules as $module) {
}
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
+ // Check module relatonships to show warning message.
+ $url = htmlentities('index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo']);
+
// Delete module.
- $data[9] = '';
+ $data[9] = '';
+
$data[9] .= html_print_image(
'images/cross.png',
true,
@@ -1309,8 +1313,7 @@ foreach ($modules as $module) {
}
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
- echo '';
}
@@ -1352,7 +1357,18 @@ if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php
index 293977f51f..baf18ab41b 100755
--- a/pandora_console/include/ajax/module.php
+++ b/pandora_console/include/ajax/module.php
@@ -61,6 +61,8 @@ if (check_login()) {
0
);
+ $get_children_modules = (bool) get_parameter('get_children_modules', false);
+
$get_data_dataMatrix = (bool) get_parameter(
'get_data_dataMatrix',
0
@@ -1629,4 +1631,36 @@ if (check_login()) {
return;
}
+
+ if ($get_children_modules === true) {
+ $parent_modules = get_parameter('parent_modulues', false);
+ $children_selected = [];
+
+ if ($parent_modules === false) {
+ $children_selected = false;
+ } else {
+ foreach ($parent_modules as $parent) {
+ $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'], $parent_modules);
+ $child_exist = in_array($child, $children_selected);
+
+ if ($module_exist === false && $child_exist === false) {
+ array_push($children_selected, $child);
+ }
+ }
+ }
+ }
+
+ if (empty($children_selected) === true) {
+ $children_selected = false;
+ }
+
+ echo json_encode($children_selected);
+ return;
+ }
}
diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php
index 06f64f61b0..15c6da909e 100755
--- a/pandora_console/include/functions_modules.php
+++ b/pandora_console/include/functions_modules.php
@@ -3992,16 +3992,28 @@ 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)
+function get_children_module($id_module, $fields=false, $recursion=false)
{
- $children_module_data = db_get_all_rows_sql(
- 'SELECT *
- FROM tagente_modulo
- WHERE parent_module_id = '.$id_module
+ $children_module_data = db_get_all_rows_filter(
+ 'tagente_modulo',
+ ['parent_module_id' => $id_module],
+ $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;
}