From fcccff080fcfb784354f4bf44d863cb4482a469e Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Thu, 8 Jul 2010 11:23:59 -0700 Subject: Bug 574556: Refactor Search.pm so that we're not doing $$some_var everywhere. Instead, we pass around a hashref and update the hashref. This patch also includes some cleanup for bugs surrounding percentage_complete, attachments.isobsolete, attachments.ispatch, and owner_idle_time. r=mkanat, a=mkanat --- Bugzilla/Group.pm | 49 +++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) (limited to 'Bugzilla/Group.pm') diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm index f047ef365..29b2a2f1c 100644 --- a/Bugzilla/Group.pm +++ b/Bugzilla/Group.pm @@ -185,6 +185,16 @@ sub products { #### Methods #### ############################### +sub check_members_are_visible { + my $self = shift; + my $user = Bugzilla->user; + return if !Bugzilla->params->{'usevisibilitygroups'}; + my $is_visible = grep { $_->id == $_ } @{ $user->visible_groups_inherited }; + if (!$is_visible) { + ThrowUserError('group_not_visible', { group => $self }); + } +} + sub set_description { $_[0]->set('description', $_[1]); } sub set_is_active { $_[0]->set('isactive', $_[1]); } sub set_name { $_[0]->set('name', $_[1]); } @@ -407,25 +417,6 @@ sub create { return $group; } -sub ValidateGroupName { - my ($name, @users) = (@_); - my $dbh = Bugzilla->dbh; - my $query = "SELECT id FROM groups " . - "WHERE name = ?"; - if (Bugzilla->params->{'usevisibilitygroups'}) { - my @visible = (-1); - foreach my $user (@users) { - $user && push @visible, @{$user->visible_groups_direct}; - } - my $visible = join(', ', @visible); - $query .= " AND id IN($visible)"; - } - my $sth = $dbh->prepare($query); - $sth->execute($name); - my ($ret) = $sth->fetchrow_array(); - return $ret; -} - ############################### ### Validators ### ############################### @@ -486,7 +477,6 @@ Bugzilla::Group - Bugzilla group class. my $icon_url = $group->icon_url; my $is_active_bug_group = $group->is_active_bug_group; - my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users); my @groups = Bugzilla::Group->get_all; =head1 DESCRIPTION @@ -506,24 +496,15 @@ normally does, this function also makes the new group be inherited by the C group. That is, the C group will automatically be a member of this group. -=item C - - Description: ValidateGroupName checks to see if ANY of the users - in the provided list of user objects can see the - named group. - - Params: $name - String with the group name. - @users - An array with Bugzilla::User objects. - - Returns: It returns the group id if successful - and undef otherwise. - -=back - =head1 METHODS =over +=item C + +Throws an error if this group is not visible (according to +visibility groups) to the currently-logged-in user. + =item C =over -- cgit v1.2.3-24-g4f1b