From 8c071532e9fe8a51d2f087a9f58bceda4b26379e Mon Sep 17 00:00:00 2001 From: Calvo Date: Thu, 19 Jan 2023 10:34:13 +0100 Subject: [PATCH 1/3] Added child module delete warning --- .../godmode/agentes/module_manager.php | 35 +++++++++++++++++-- pandora_console/include/functions_modules.php | 10 +++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index e315ec3d16..a5df5e31c0 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -1283,9 +1283,14 @@ foreach ($modules as $module) { } if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { + // Check module relatonships to show warning message. + $module_children = json_encode(get_children_module($module['id_agente_modulo'], 'nombre')); + $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, @@ -1394,4 +1399,30 @@ if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { window.location = window.location + "&checked=true"; } } + + function delete_module_warning(children_json, url) { + var message = ''; + var children = JSON.parse(children_json); + var ret = false; + + if(children != false) { + message += '
' + '' + ''; + } + + ret = confirmDialog({ + title: "", + message: message, + onAccept: function() { + window.location.href = url; + } + }); + + return false; + + + } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index e414c64e39..d45b2f19ce 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3988,12 +3988,12 @@ function recursive_get_dt_from_modules_tree(&$f_modules, $modules, $deep) * @param integer $id_module Id module * @return array Children module data */ -function get_children_module($id_module) +function get_children_module($id_module, $fields=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 ); return $children_module_data; From 5d0826f412b365300b0378f190f9e7d2fa6969c6 Mon Sep 17 00:00:00 2001 From: Calvo Date: Tue, 24 Jan 2023 12:26:49 +0100 Subject: [PATCH 2/3] Delete modules with children message --- .../godmode/agentes/module_manager.php | 63 +++++++++++++++---- pandora_console/include/ajax/module.php | 34 ++++++++++ 2 files changed, 86 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index a5df5e31c0..f2045bf7a1 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -1284,12 +1284,11 @@ foreach ($modules as $module) { if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { // Check module relatonships to show warning message. - $module_children = json_encode(get_children_module($module['id_agente_modulo'], 'nombre')); $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] = '
'; + onClick="get_children_modules(false, \''.$module['id_agente_modulo'].'\', \''.$url.'\')">'; $data[9] .= html_print_image( 'images/cross.png', @@ -1314,8 +1313,7 @@ foreach ($modules as $module) { } if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { - echo '
'; + echo ''; } html_print_table($table); @@ -1349,6 +1347,8 @@ if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { false, 'class="sub next"' ); + + echo ''; echo '
'; } @@ -1357,7 +1357,18 @@ if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {