From: Koosha Khajeh Moogahi Date: Thu, 8 Nov 2012 18:56:16 +0000 (+0100) Subject: Bug 808300: Requesting data for your own account using User.get should also returns... X-Git-Tag: bugzilla-4.4rc1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af793d17204b196fdff9c705d697f35307b13f70;p=thirdparty%2Fbugzilla.git Bug 808300: Requesting data for your own account using User.get should also returns groups you belong to r/a=LpSolit --- diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm index 2a62c3b5a8..be0de43eee 100644 --- a/Bugzilla/WebService/User.pm +++ b/Bugzilla/WebService/User.pm @@ -211,21 +211,27 @@ sub get { name => $self->type('string', $user->login), email => $self->type('string', $user->email), can_login => $self->type('boolean', $user->is_enabled ? 1 : 0), - groups => $self->_filter_bless_groups($user->groups), }; - + if (Bugzilla->user->in_group('editusers')) { $user_info->{email_enabled} = $self->type('boolean', $user->email_enabled); $user_info->{login_denied_text} = $self->type('string', $user->disabledtext); } - + if (Bugzilla->user->id == $user->id) { $user_info->{saved_searches} = [map { $self->_query_to_hash($_) } @{ $user->queries }]; $user_info->{saved_reports} = [map { $self->_report_to_hash($_) } @{ $user->reports }]; } - + + if (Bugzilla->user->id == $user->id || Bugzilla->user->in_group('editusers')) { + $user_info->{groups} = [map {$self->_group_to_hash($_)} @{ $user->groups }]; + } + else { + $user_info->{groups} = $self->_filter_bless_groups($user->groups); + } + push(@users, filter($params, $user_info)); -} + } return { users => \@users }; } @@ -331,7 +337,7 @@ sub _filter_bless_groups { my @filtered_groups; foreach my $group (@$groups) { - next unless ($user->in_group('editusers') || $user->can_bless($group->id)); + next unless $user->can_bless($group->id); push(@filtered_groups, $self->_group_to_hash($group)); } @@ -790,8 +796,11 @@ disabled/closed. =item groups -C An array of group hashes the user is a member of. Each hash describes -the group and contains the following items: +C An array of group hashes the user is a member of. If the currently +logged in user is querying his own account or is a member of the 'editusers' +group, the array will contain all the groups that the user is a +member of. Otherwise, the array will only contain groups that the logged in +user can bless. Each hash describes the group and contains the following items: =over