From f9c5db2e4a75c67269386a6673b83a7ddde62d05 Mon Sep 17 00:00:00 2001 From: zarzuelo <zarzuelo@gmail.com> Date: Wed, 17 Jul 2013 16:14:52 +0000 Subject: [PATCH] 2013-07-17 Sergio Martin <sergio.martin@artica.es> * include/functions_users.php include/functions_groups.php operation/events/events_list.php: Fixed the visibility of the users in the events view filter. Now the user can only filter by the users of the groups where the user belongs git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8539 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++++++++ pandora_console/include/functions_groups.php | 4 +++- pandora_console/include/functions_users.php | 22 +++++++++++++++++++ .../operation/events/events_list.php | 6 +++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 40e37c4bac..26d7bc9974 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2013-07-17 Sergio Martin <sergio.martin@artica.es> + + * include/functions_users.php + include/functions_groups.php + operation/events/events_list.php: Fixed the visibility + of the users in the events view filter. Now the user + can only filter by the users of the groups where the + user belongs + 2013-07-17 Sergio Martin <sergio.martin@artica.es> * operation/menu.php diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 86a1bd9980..a4fd9cca27 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -592,10 +592,12 @@ function groups_get_id ($group_name, $returnAllGroup = false) { * Get all the users belonging to a group. * * @param int $id_group The group id to look for + * @param mixed filter array + * @param bool True if users with all permissions in the group are retrieved * * @return array An array with all the users or an empty array */ -function groups_get_users ($id_group, $filter = false) { +function groups_get_users ($id_group, $filter = false, $return_user_all = false) { global $config; if (! is_array ($filter)) diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index d901b653c7..f64329482d 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -808,4 +808,26 @@ function users_can_manage_group_all($id_group = 0) { return false; } + +/** + * Get the users that belongs to the same groups of the current user + * + * @return mixed Array with id_user as index and value + */ +function users_get_user_users() { + global $config; + + $user_groups = users_get_groups(); + + $user_users = array(); + foreach($user_groups as $id_user_group => $name_user_group) { + $group_users = groups_get_users($id_user_group, false, true); + + foreach($group_users as $gu) { + $user_users[$gu['id_user']] = $gu['id_user']; + } + } + + return $user_users; +} ?> diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 9913b49798..a97afb1b9c 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -387,8 +387,10 @@ $table_advanced->rowclass[] = ''; $data = array(); $data[0] = __('User ack.') . '<br>'; -$users = users_get_info (); -$data[0] .= html_print_select($users, "id_user_ack", $id_user_ack, '', + +$user_users = users_get_user_users(); + +$data[0] .= html_print_select($user_users, "id_user_ack", $id_user_ack, '', __('Any'), 0, true); $data[1] = ''; $table_advanced->data[] = $data;