From ca06c57995ed327879e4c23b58e1330d4bd27d18 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sun, 25 Jan 2009 18:49:30 +0000 Subject: Bug 405355: Move flatten_group_membership() from User.pm to Group.pm - Patch by arbingersys r/a=LpSolit --- Bugzilla/User.pm | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 0c0f45bc0..fe04856aa 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -48,6 +48,7 @@ use Bugzilla::User::Setting; use Bugzilla::Product; use Bugzilla::Classification; use Bugzilla::Field; +use Bugzilla::Group; use Scalar::Util qw(blessed); use DateTime::TimeZone; @@ -830,7 +831,7 @@ sub visible_groups_inherited { return $self->{visible_groups_inherited} if defined $self->{visible_groups_inherited}; return [] unless $self->id; my @visgroups = @{$self->visible_groups_direct}; - @visgroups = @{$self->flatten_group_membership(@visgroups)}; + @visgroups = @{Bugzilla::Group->flatten_group_membership(@visgroups)}; $self->{visible_groups_inherited} = \@visgroups; return $self->{visible_groups_inherited}; } @@ -992,30 +993,6 @@ sub can_bless { return grep($_->id == $group_id, @{ $self->bless_groups }) ? 1 : 0; } -sub flatten_group_membership { - my ($self, @groups) = @_; - - my $dbh = Bugzilla->dbh; - my $sth; - my @groupidstocheck = @groups; - my %groupidschecked = (); - $sth = $dbh->prepare("SELECT member_id FROM group_group_map - WHERE grantor_id = ? - AND grant_type = " . GROUP_MEMBERSHIP); - while (my $node = shift @groupidstocheck) { - $sth->execute($node); - my $member; - while (($member) = $sth->fetchrow_array) { - if (!$groupidschecked{$member}) { - $groupidschecked{$member} = 1; - push @groupidstocheck, $member; - push @groups, $member unless grep $_ == $member, @groups; - } - } - } - return \@groups; -} - sub match { # Generates a list of users whose login name (email address) or real name # matches a substring or wildcard. @@ -2049,14 +2026,6 @@ Returns a reference to an array of users. The array is populated with hashrefs containing the login, identity and visibility. Users that are not visible to this user will have 'visible' set to zero. -=item C - -Accepts a list of groups and returns a list of all the groups whose members -inherit membership in any group on the list. So, we can determine if a user -is in any of the groups input to flatten_group_membership by querying the -user_group_map for any user with DIRECT or REGEXP membership IN() the list -of groups returned. - =item C Returns a reference to an array of group objects. Groups the user belong to -- cgit v1.2.3-24-g4f1b