diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e74d317361..7c524aa80f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2011-09-01 Miguel de Dios + + * include/functions_users.php: added the function "users_get_first_group" + another parameter, $all_group, to return all group or not, by default is + true. + + Fixes: #3401582 + 2011-09-01 Miguel de Dios * ChangeLog: sorry I mistake the number of bug in Sourceforge tracker. diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index 66b0ec999b..83c77062d4 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -158,11 +158,20 @@ function users_get_groups_tree($id_user = false, $privilege = "AR", $returnAllGr * * @param string User id * @param string The privilege to evaluate + * @param bool $all_group Flag to return all group, by default true; * * @return array The first group where the user has certain privileges. */ -function users_get_first_group ($id_user = false, $privilege = "AR") { - return array_shift (array_keys (users_get_groups ($id_user, $privilege))); +function users_get_first_group ($id_user = false, $privilege = "AR", $all_group = true) { + $groups = array_keys (users_get_groups ($id_user, $privilege)); + + $return = array_shift($groups); + + if ((!$all_group) && ($return == 0)) { + $return = array_shift($groups); + } + + return $return; } /**