diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Constants.pm | 6 | ||||
-rw-r--r-- | Bugzilla/Group.pm | 51 | ||||
-rw-r--r-- | Bugzilla/Search.pm | 23 |
3 files changed, 60 insertions, 20 deletions
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index a3e16251c..8837d2276 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -62,6 +62,9 @@ use base qw(Exporter); GROUP_BLESS GROUP_VISIBLE + MAILTO_USER + MAILTO_GROUP + DEFAULT_COLUMN_LIST DEFAULT_QUERY_NAME @@ -206,6 +209,9 @@ use constant GROUP_MEMBERSHIP => 0; use constant GROUP_BLESS => 1; use constant GROUP_VISIBLE => 2; +use constant MAILTO_USER => 0; +use constant MAILTO_GROUP => 1; + # The default list of columns for buglist.cgi use constant DEFAULT_COLUMN_LIST => ( "bug_severity", "priority", "rep_platform","assigned_to", diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm new file mode 100644 index 000000000..2cb8e5342 --- /dev/null +++ b/Bugzilla/Group.pm @@ -0,0 +1,51 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Bugzilla Bug Tracking System. +# +# The Initial Developer of the Original Code is Netscape Communications +# Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): Joel Peshkin <bugreport@peshkin.net> +# Erik Stambaugh <erik@dasbistro.com> + +use strict; + +package Bugzilla::Group; + +use Bugzilla::Config; + +# ValidateGroupName checks to see if ANY of the users in the provided list +# of user objects can see the named group. It returns the group id if +# successful and undef otherwise. +sub ValidateGroupName { + my ($name, @users) = (@_); + my $dbh = Bugzilla->dbh; + my $query = "SELECT id FROM groups " . + "WHERE name = ?"; + if (Param('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; +} + +1; diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 816b4b0a1..e58278f48 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -40,6 +40,7 @@ use Bugzilla::Config; use Bugzilla::Error; use Bugzilla::Util; use Bugzilla::Constants; +use Bugzilla::Group; use Date::Format; use Date::Parse; @@ -382,7 +383,7 @@ sub init { ( "^(?:assigned_to|reporter|qa_contact),(?:notequals|equals|anyexact),%group\\.(\\w+)%" => sub { my $group = $1; - my $groupid = ValidateGroupName( $group, ($user)); + my $groupid = Bugzilla::Group::ValidateGroupName( $group, ($user)); $groupid || ThrowUserError('invalid_group_name',{name => $group}); my @childgroups = @{$user->flatten_group_membership($groupid)}; my $table = "user_group_map_$chartid"; @@ -419,7 +420,7 @@ sub init { "^(?:cc),(?:notequals|equals|anyexact),%group\\.(\\w+)%" => sub { my $group = $1; - my $groupid = ValidateGroupName( $group, ($user)); + my $groupid = Bugzilla::Group::ValidateGroupName( $group, ($user)); $groupid || ThrowUserError('invalid_group_name',{name => $group}); my @childgroups = @{$user->flatten_group_membership($groupid)}; my $chartseq = $chartid; @@ -1495,24 +1496,6 @@ sub pronoun { return 0; } -# ValidateGroupName checks to see if ANY of the users in the provided list -# of user objects can see the named group. It returns the group id if -# successful and undef otherwise. -sub ValidateGroupName { - my ($name, @users) = (@_); - my @visible = (-1); - foreach my $user (@users) { - $user && push @visible, @{$user->visible_groups_direct}; - } - my $visible = join(', ', @visible); - my $dbh = Bugzilla->dbh; - my $sth = $dbh->prepare("SELECT id FROM groups " . - "WHERE name = ? AND id IN($visible)"); - $sth->execute($name); - my ($ret) = $sth->fetchrow_array(); - return $ret; -} - # Validate that the query type is one we can deal with sub IsValidQueryType { |