summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Group.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-20 23:20:57 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-20 23:20:57 +0200
commit1dc3eb46af07596e64c6c3bb1cbb82cf121ad8b1 (patch)
tree286b8e8baa70366265fb586396c79f916f6da9c2 /Bugzilla/Group.pm
parentce4cf0862c192c334e83de08f30a437da3aea888 (diff)
downloadbugzilla-1dc3eb46af07596e64c6c3bb1cbb82cf121ad8b1.tar.gz
bugzilla-1dc3eb46af07596e64c6c3bb1cbb82cf121ad8b1.tar.xz
Bug 579797: Restore ValidateGroupName in Bugzilla::Group, because it is
still in use by the whining system r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/Group.pm')
-rw-r--r--Bugzilla/Group.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm
index eef0a70cd..11a27e2e6 100644
--- a/Bugzilla/Group.pm
+++ b/Bugzilla/Group.pm
@@ -420,6 +420,25 @@ 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 ###
###############################
@@ -480,6 +499,7 @@ 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
@@ -499,8 +519,21 @@ 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