summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Group.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-08 20:23:59 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-08 20:23:59 +0200
commitfcccff080fcfb784354f4bf44d863cb4482a469e (patch)
treeee557cd4023acaa487b35897e429b1b3b3868e87 /Bugzilla/Group.pm
parent0e8eb4037e3931e408aeb98f2ed5760710c961a2 (diff)
downloadbugzilla-fcccff080fcfb784354f4bf44d863cb4482a469e.tar.gz
bugzilla-fcccff080fcfb784354f4bf44d863cb4482a469e.tar.xz
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
Diffstat (limited to 'Bugzilla/Group.pm')
-rw-r--r--Bugzilla/Group.pm49
1 files changed, 15 insertions, 34 deletions
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<admin> group. That is, the C<admin> group will automatically
be a member of this group.
-=item C<ValidateGroupName($name, @users)>
-
- 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<check_members_are_visible>
+
+Throws an error if this group is not visible (according to
+visibility groups) to the currently-logged-in user.
+
=item C<check_remove>
=over