summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Search.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Search.pm')
-rw-r--r--Bugzilla/Search.pm36
1 files changed, 29 insertions, 7 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 482daca5c..d6e7a9b7f 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -29,7 +29,7 @@ use strict;
# The caller MUST require CGI.pl and globals.pl before using this
-use vars qw($userid $usergroupset);
+use vars qw($userid);
package Bugzilla::Search;
@@ -117,7 +117,7 @@ sub init {
my @legal_fields = ("product", "version", "rep_platform", "op_sys",
"bug_status", "resolution", "priority", "bug_severity",
"assigned_to", "reporter", "component",
- "target_milestone", "groupset");
+ "target_milestone", "bug_group");
foreach my $field (keys %F) {
if (lsearch(\@legal_fields, $field) != -1) {
@@ -322,6 +322,12 @@ sub init {
push(@wherepart, "$table.bug_id = bugs.bug_id");
$f = "$table.thetext";
},
+ "^bug_group,(?!changed)" => sub {
+ push(@supptables, "LEFT JOIN bug_group_map bug_group_map_$chartid ON bugs.bug_id = bug_group_map_$chartid.bug_id");
+
+ push(@supptables, "LEFT JOIN groups groups_$chartid ON groups_$chartid.id = bug_group_map_$chartid.group_id");
+ $f = "groups_$chartid.name";
+ },
"^attachments\..*," => sub {
my $table = "attachments_$chartid";
push(@supptables, "attachments $table");
@@ -747,7 +753,7 @@ sub init {
# chart -1 is generated by other code above, not from the user-
# submitted form, so we'll blindly accept any values in chart -1
if ((!$chartfields{$f}) && ($chart != -1)) {
- my $errstr = "Can't use " . html_quote($f) . " as a field name. " .
+ my $errstr = "Can't use $f as a field name. " .
"If you think you're getting this in error, please copy the " .
"entire URL out of the address bar at the top of your browser " .
"window and email it to <109679\@bugzilla.org>";
@@ -807,11 +813,27 @@ sub init {
$suppseen{$str} = 1;
}
}
- my $query = ("SELECT DISTINCT " . join(', ', @fields) .
+ my $query = ("SELECT DISTINCT " .
+ join(', ', @fields) .
+ ", COUNT(DISTINCT ugmap.group_id) AS cntuseringroups, " .
+ " COUNT(DISTINCT bgmap.group_id) AS cntbugingroups, " .
+ " ((COUNT(DISTINCT ccmap.who) AND cclist_accessible) " .
+ " OR ((bugs.reporter = $::userid) AND bugs.reporter_accessible) " .
+ " OR bugs.assigned_to = $::userid ) AS canseeanyway " .
" FROM $suppstring" .
- " WHERE " . join(' AND ', (@wherepart, @andlist)));
-
- $query = &::SelectVisible($query, $::userid, $::usergroupset);
+ " LEFT JOIN bug_group_map AS bgmap " .
+ " ON bgmap.bug_id = bugs.bug_id " .
+ " LEFT JOIN user_group_map AS ugmap " .
+ " ON bgmap.group_id = ugmap.group_id " .
+ " AND ugmap.user_id = $::userid " .
+ " AND ugmap.isbless = 0" .
+ " LEFT JOIN cc AS ccmap " .
+ " ON ccmap.who = $::userid AND ccmap.bug_id = bugs.bug_id " .
+ " WHERE " . join(' AND ', (@wherepart, @andlist)) .
+ " GROUP BY bugs.bug_id " .
+ " HAVING cntuseringroups = cntbugingroups" .
+ " OR canseeanyway"
+ );
if ($debug) {
print "<p><code>" . value_quote($query) . "</code></p>\n";