From a4da4bbc8df7cf8387c744694a86def8dc704022 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 31 May 2016 10:05:23 +0200 Subject: [PATCH] Added a function to dashboard groups checkboxes. Ticket#2598 --- pandora_console/include/functions_groups.php | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 181aa2053b..23b73b498e 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -230,6 +230,36 @@ function groups_check_used($idGroup) { return $return; } +/** + * Return a array of id_group of childrens (to branches down) + * + * @param integer $parent The id_group parent to search the childrens. + * @param array $groups The groups, its for optimize the querys to DB. + */ +function groups_get_childrens_ids($parent, $groups = null) { + if (empty($groups)) { + $groups = db_get_all_rows_in_table('tgrupo'); + } + + $return = ''; + + foreach ($groups as $key => $group) { + if ($group['id_grupo'] == 0) { + continue; + } + + if ($group['parent'] == $parent) { + $return .= $group['id_grupo'] . ","; + $propagate = db_get_value('propagate', 'tgrupo', 'id_grupo', $group['id_grupo']); + if ($propagate) { + $return .= groups_get_childrens_ids($group['id_grupo']); + } + } + } + + return $return; +} + /** * Return a array of id_group of childrens (to branches down) *