summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/lib/Reports
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-08-24 19:44:36 +0200
committerByron Jones <glob@mozilla.com>2015-08-24 19:44:36 +0200
commitc63ecc86155c5bb6fb85e6412fe7c6e80ba33a65 (patch)
tree8ad223b0d9b3006c3ba454a74ea3cc6500989b21 /extensions/BMO/lib/Reports
parent24e4c03268aa627947f73703f4c283b9b8087d5e (diff)
downloadbugzilla-c63ecc86155c5bb6fb85e6412fe7c6e80ba33a65.tar.gz
bugzilla-c63ecc86155c5bb6fb85e6412fe7c6e80ba33a65.tar.xz
Bug 1197696 - group_members report doesn't display nested inherited groups
Diffstat (limited to 'extensions/BMO/lib/Reports')
-rw-r--r--extensions/BMO/lib/Reports/Groups.pm55
1 files changed, 40 insertions, 15 deletions
diff --git a/extensions/BMO/lib/Reports/Groups.pm b/extensions/BMO/lib/Reports/Groups.pm
index 7fa86b243..4a831fab3 100644
--- a/extensions/BMO/lib/Reports/Groups.pm
+++ b/extensions/BMO/lib/Reports/Groups.pm
@@ -14,6 +14,7 @@ use Bugzilla::Error;
use Bugzilla::Group;
use Bugzilla::User;
use Bugzilla::Util qw(trim);
+use JSON qw(encode_json);
sub admins_report {
my ($vars) = @_;
@@ -163,7 +164,7 @@ sub membership_report {
}
sub members_report {
- my ($vars) = @_;
+ my ($page, $vars) = @_;
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
my $cgi = Bugzilla->cgi;
@@ -196,20 +197,13 @@ sub members_report {
my $group_obj = Bugzilla::Group->new({ name => $group });
$vars->{'group'} = $group;
- # direct members
- my @types = (
- {
- name => 'direct',
- members => _filter_userlist($group_obj->members_direct, $include_disabled),
- },
- );
-
- # indirect members, by group
- foreach my $member_group (sort @{ $group_obj->grant_direct(GROUP_MEMBERSHIP) }) {
+ my @types;
+ my $members = $group_obj->members_complete();
+ foreach my $name (sort keys %$members) {
push @types, {
- name => $member_group->name,
- members => _filter_userlist($member_group->members_direct, $include_disabled),
- },
+ name => ($name eq '_direct' ? 'direct' : $name),
+ members => _filter_userlist($members->{$name}),
+ }
}
# make it easy for the template to detect an empty group
@@ -243,7 +237,38 @@ sub members_report {
}
}
- $vars->{'types'} = \@types;
+ if ($page eq 'group_members.json') {
+ my %users;
+ foreach my $rh (@types) {
+ my $group_name = $rh->{name} eq '_direct' ? 'direct' : $rh->{name};
+ foreach my $member (@{ $rh->{members} }) {
+ my $login = $member->login;
+ if (exists $users{$login}) {
+ push @{ $users{$login}->{groups} }, $group_name;
+ }
+ else {
+ $users{$login} = {
+ login => $login,
+ membership => $rh->{name} eq '_direct' ? 'direct' : 'indirect',
+ group => $group_name,
+ groups => [ $group_name ],
+ lastseen => $member->{lastseen},
+ };
+ }
+ }
+ }
+ $vars->{types_json} = JSON->new->pretty->canonical->utf8->encode([ values %users ]);
+ }
+ else {
+ my %users;
+ foreach my $rh (@types) {
+ foreach my $member (@{ $rh->{members} }) {
+ $users{$member->login} = 1 unless exists $users{$member->login};
+ }
+ }
+ $vars->{types} = \@types;
+ $vars->{count} = scalar(keys %users);
+ }
}
sub _filter_userlist {