From 0686982055319ade550f937f92f59448e8de1f16 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 28 Dec 2018 13:09:37 +0100 Subject: [PATCH] Fixed agents_get_group_agents while trying to get agent list from target group Former-commit-id: 8a005e1574760688f5823cc854a287774c8c828b --- pandora_console/include/functions_agents.php | 6 ++++-- pandora_console/include/functions_groups.php | 7 ++++--- pandora_console/operation/agentes/ver_agente.php | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index d69a27d8fe..7b4592171b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -827,7 +827,8 @@ function agents_get_group_agents ( $filter = array(); - if (!$noACL) { + // check available groups for target user only if asking for 'All' group + if (!$noACL && $id_group == 0) { $id_group = $id_group == 0 ? array_keys(users_get_groups(false, "AR", false)) : groups_safe_acl($config["id_user"], $id_group, "AR"); @@ -848,7 +849,8 @@ function agents_get_group_agents ( $id_group = groups_get_id_recursive($id_group, true); } - if (!$noACL) { + // check available groups for target user only if asking for 'All' group + if (!$noACL && $id_group == 0) { $id_group = array_keys( users_get_groups(false, "AR", true, false, (array)$id_group)); } diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index bfc5d3af55..be2c23518d 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -441,7 +441,7 @@ function groups_get_all($groupWithAgents = false) { * Get all groups recursive from an initial group. * * @param int Id of the parent group - * @param bool Whether to return All group or not + * @param bool Whether to force recursive search ignoring propagation (true) or not (false) * * @return Array with all result groups */ @@ -451,10 +451,11 @@ function groups_get_id_recursive($id_parent, $all = false) { $return = array_merge($return, array($id_parent)); //Check propagate - $id = db_get_value_filter('id_grupo', 'tgrupo', array('id_grupo' => $id_parent, 'propagate' => 1)); + $propagate = db_get_value_filter('propagate', 'tgrupo', array('id_grupo' => $id_parent)); - if (($id !== false) || $all) { + if (($propagate != 1) || $all) { $children = db_get_all_rows_filter("tgrupo", array('parent' => $id_parent, 'disabled' => 0), array('id_grupo')); + if ($children === false) { $children = array(); } diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index c26096f21a..219c3807b4 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -110,7 +110,7 @@ if (is_ajax ()) { } // Perform search - $agents = agents_get_group_agents($id_group,$filter,"lower",false,false,false,'|',$cluster_mode); + $agents = agents_get_group_agents($id_group,$filter,"lower",false,$recursion,false,'|',$cluster_mode); if (empty($agents)) $agents = array(); // Add keys prefix