summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbugreport%peshkin.net <>2004-07-13 10:52:05 +0200
committerbugreport%peshkin.net <>2004-07-13 10:52:05 +0200
commita74271e7d1081c86862151116531c5f42f3e4c7d (patch)
treea9d3ea4fb5e320cdcc52bddade48e9509b96344e
parent8c1a3e8ff7f6c05ee9e7f45871cea073c4c26c91 (diff)
downloadbugzilla-a74271e7d1081c86862151116531c5f42f3e4c7d.tar.gz
bugzilla-a74271e7d1081c86862151116531c5f42f3e4c7d.tar.xz
Bug 226434: Add %reporter%, %user%, and %assignee% pronouns to boolean charts
r=jouni a=justdave
-rw-r--r--Bugzilla/Search.pm86
-rw-r--r--template/en/default/global/user-error.html.tmpl4
2 files changed, 80 insertions, 10 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index aeaf7b0d1..42969cd2d 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -322,6 +322,12 @@ sub init {
my %funcsbykey;
my @funcdefs =
(
+ "^(?:assigned_to|reporter|qa_contact),(?:equals|anyexact),(%\\w+%)" => sub {
+ $term = "bugs.$f = " . pronoun($1, $user);
+ },
+ "^(?:assigned_to|reporter|qa_contact),(?:notequals),(%\\w+%)" => sub {
+ $term = "bugs.$f <> " . pronoun($1, $user);
+ },
"^(assigned_to|reporter)," => sub {
push(@supptables, "profiles AS map_$f");
push(@wherepart, "bugs.$f = map_$f.userid");
@@ -333,11 +339,34 @@ sub init {
$f = "map_$f.login_name";
},
+ "^cc,(?:equals|anyexact),(%\\w+%)" => sub {
+ my $match = pronoun($1, $user);
+ my $chartseq = $chartid;
+ if ($chartid eq "") {
+ $chartseq = "CC$sequence";
+ $sequence++;
+ }
+ push(@supptables, "LEFT JOIN cc cc_$chartseq
+ ON bugs.bug_id = cc_$chartseq.bug_id
+ AND cc_$chartseq.who = $match");
+ $term = "cc_$chartseq.who IS NOT NULL";
+ },
+ "^cc,(?:notequals),(%\\w+%)" => sub {
+ my $match = pronoun($1, $user);
+ my $chartseq = $chartid;
+ if ($chartid eq "") {
+ $chartseq = "CC$sequence";
+ $sequence++;
+ }
+ push(@supptables, "LEFT JOIN cc cc_$chartseq
+ ON bugs.bug_id = cc_$chartseq.bug_id
+ AND cc_$chartseq.who = $match");
+ $term = "cc_$chartseq.who IS NULL";
+ },
"^cc,(anyexact|substring)" => sub {
my $list;
$list = $self->ListIDsForEmail($t, $v);
- my $chartseq;
- $chartseq = $chartid;
+ my $chartseq = $chartid;
if ($chartid eq "") {
$chartseq = "CC$sequence";
$sequence++;
@@ -355,8 +384,7 @@ sub init {
}
},
"^cc," => sub {
- my $chartseq;
- $chartseq = $chartid;
+ my $chartseq = $chartid;
if ($chartid eq "") {
$chartseq = "CC$sequence";
$sequence++;
@@ -442,11 +470,27 @@ sub init {
push(@fields, $select_term);
}
},
- "^commenter," => sub {
- my $chartseq;
+ "^commenter,(?:equals|anyexact),(%\\w+%)" => sub {
+ my $match = pronoun($1, $user);
+ my $chartseq = $chartid;
+ if ($chartid eq "") {
+ $chartseq = "LD$sequence";
+ $sequence++;
+ }
+ my $table = "longdescs_$chartseq";
+ my $extra = "";
+ if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) {
+ $extra = "AND $table.isprivate < 1";
+ }
+ push(@supptables, "LEFT JOIN longdescs $table
+ ON $table.bug_id = bugs.bug_id $extra
+ AND $table.who IN ($match)");
+ $term = "$table.who IS NOT NULL";
+ },
+ "^commenter," => sub {
+ my $chartseq = $chartid;
my $list;
$list = $self->ListIDsForEmail($t, $v);
- $chartseq = $chartid;
if ($chartid eq "") {
$chartseq = "LD$sequence";
$sequence++;
@@ -1023,13 +1067,15 @@ sub init {
# a valid field name, which means that it's ok.
trick_taint($f);
$q = &::SqlQuote($v);
+ my $rhs = $v;
+ $rhs =~ tr/,//;
my $func;
$term = undef;
foreach my $key (@funcnames) {
- if ("$f,$t" =~ m/$key/) {
+ if ("$f,$t,$rhs" =~ m/$key/) {
my $ref = $funcsbykey{$key};
if ($debug) {
- print "<p>$key ($f , $t ) => ";
+ print "<p>$key ($f , $t , $rhs ) => ";
}
$ff = $f;
if ($f !~ /\./) {
@@ -1037,7 +1083,7 @@ sub init {
}
&$ref;
if ($debug) {
- print "$f , $t , $term</p>";
+ print "$f , $t , $v , $term</p>";
}
if ($term) {
last;
@@ -1254,4 +1300,24 @@ sub getSQL {
return $self->{'sql'};
}
+sub pronoun {
+ my ($noun, $user) = (@_);
+ if ($noun eq "%user%") {
+ if ($user) {
+ return $user->id;
+ } else {
+ ThrowUserError('login_required_for_pronoun');
+ }
+ }
+ if ($noun eq "%reporter%") {
+ return "bugs.reporter";
+ }
+ if ($noun eq "%assignee%") {
+ return "bugs.assigned_to";
+ }
+ if ($noun eq "%qacontact%") {
+ return "bugs.qa_contact";
+ }
+ return 0;
+}
1;
diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl
index 5ff7fedec..e4c9863df 100644
--- a/template/en/default/global/user-error.html.tmpl
+++ b/template/en/default/global/user-error.html.tmpl
@@ -414,6 +414,10 @@
[% title = "Login Name Required" %]
You must enter a login name when requesting to change your password.
+ [% ELSIF error == "login_required_for_pronoun" %]
+ [% title = "Login Name Required" %]
+ You must enter a login name when using your login as a pronoun.
+
[% ELSIF error == "milestone_required" %]
[% title = "Milestone Required" %]
You must determine a target milestone for [% terms.bug %]