From 89d5b490bf542f56b0e622a62f93e361bd41aba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Mon, 7 Mar 2022 10:45:11 +0100 Subject: [PATCH] Clean filtered references for parent modules --- .../include/class/TreeGroup.class.php | 24 +++++++------------ pandora_console/operation/tree.php | 8 +++---- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php index 48c64c898d..22bf18fac4 100644 --- a/pandora_console/include/class/TreeGroup.class.php +++ b/pandora_console/include/class/TreeGroup.class.php @@ -390,37 +390,29 @@ class TreeGroup extends Tree $groups[$group['id']] = $group; } - // Build the module hierarchy + // Build the module hierarchy. foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + if (isset($groups[$id]['parent']) === true && ($groups[$id]['parent'] != 0)) { $parent = $groups[$id]['parent']; - // Parent exists - if (!isset($groups[$parent]['children'])) { + // Parent exists. + if (isset($groups[$parent]['children']) === true) { $groups[$parent]['children'] = []; } - // Store a reference to the group into the parent + // Store a reference to the group into the parent. $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent + // This group was introduced into a parent. $groups[$id]['have_parent'] = true; } } - // Sort the children groups + // Sort the children groups. foreach ($groups as $id => $group) { - if (isset($groups[$id]['children'])) { + if (isset($groups[$id]['children']) === true) { usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); } } - // Filter groups and eliminates the reference to children groups out of her parent - $groups = array_filter( - $groups, - function ($group) { - return !($group['have_parent'] ?? false); - } - ); - return array_values($groups); } diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index ad11c1da46..95c8302ee4 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -323,7 +323,7 @@ html_print_image( echo "
"; echo '
'; -if (is_metaconsole()) { +if (is_metaconsole() === true) { echo ''; } @@ -331,7 +331,7 @@ enterprise_hook('close_meta_frame'); ?> - + @@ -341,12 +341,12 @@ enterprise_hook('close_meta_frame'); var treeController = TreeController.getController(); processTreeSearch(); - + $("form#tree_search").submit(function(e) { e.preventDefault(); processTreeSearch(); }); - + function processTreeSearch () { // Clear the tree if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)