Commit 1f71df24 authored by myk%mozilla.org's avatar myk%mozilla.org

Fix for bug 179881: makes the "Requests" link in the footer be "My Requests" for logged in users.

r=bbaetz a=myk
parent e008d255
...@@ -117,6 +117,12 @@ sub queue { ...@@ -117,6 +117,12 @@ sub queue {
AND flags.bug_id = bugs.bug_id AND flags.bug_id = bugs.bug_id
"; ";
# Limit query to pending requests.
$query .= " AND flags.status = '?' " unless $::FORM{'status'};
# The set of criteria by which we filter records to display in the queue.
my @criteria = ();
# A list of columns to exclude from the report because the report conditions # A list of columns to exclude from the report because the report conditions
# limit the data being displayed to exact matches for those columns. # limit the data being displayed to exact matches for those columns.
# In other words, if we are only displaying "pending" , we don't # In other words, if we are only displaying "pending" , we don't
...@@ -126,36 +132,38 @@ sub queue { ...@@ -126,36 +132,38 @@ sub queue {
# Filter requests by status: "pending", "granted", "denied", "all" # Filter requests by status: "pending", "granted", "denied", "all"
# (which means any), or "fulfilled" (which means "granted" or "denied"). # (which means any), or "fulfilled" (which means "granted" or "denied").
$::FORM{'status'} ||= "?"; if ($::FORM{'status'}) {
if ($::FORM{'status'} eq "+-") { if ($::FORM{'status'} eq "+-") {
$query .= " AND flags.status IN ('+', '-')"; push(@criteria, "flags.status IN ('+', '-')");
} push(@excluded_columns, 'status') unless $::FORM{'do_union'};
elsif ($::FORM{'status'} ne "all") { }
$query .= " AND flags.status = '$::FORM{'status'}'"; elsif ($::FORM{'status'} ne "all") {
push(@excluded_columns, 'status'); push(@criteria, "flags.status = '$::FORM{'status'}'");
push(@excluded_columns, 'status') unless $::FORM{'do_union'};
}
} }
# Filter results by exact email address of requester or requestee. # Filter results by exact email address of requester or requestee.
if (defined($::FORM{'requester'}) && $::FORM{'requester'} ne "") { if (defined($::FORM{'requester'}) && $::FORM{'requester'} ne "") {
$query .= " AND requesters.login_name = " . SqlQuote($::FORM{'requester'}); push(@criteria, "requesters.login_name = " . SqlQuote($::FORM{'requester'}));
push(@excluded_columns, 'requester'); push(@excluded_columns, 'requester') unless $::FORM{'do_union'};
} }
if (defined($::FORM{'requestee'}) && $::FORM{'requestee'} ne "") { if (defined($::FORM{'requestee'}) && $::FORM{'requestee'} ne "") {
$query .= " AND requestees.login_name = " . SqlQuote($::FORM{'requestee'}); push(@criteria, "requestees.login_name = " . SqlQuote($::FORM{'requestee'}));
push(@excluded_columns, 'requestee'); push(@excluded_columns, 'requestee') unless $::FORM{'do_union'};
} }
# Filter results by exact product or component. # Filter results by exact product or component.
if (defined($::FORM{'product'}) && $::FORM{'product'} ne "") { if (defined($::FORM{'product'}) && $::FORM{'product'} ne "") {
my $product_id = get_product_id($::FORM{'product'}); my $product_id = get_product_id($::FORM{'product'});
if ($product_id) { if ($product_id) {
$query .= " AND bugs.product_id = $product_id"; push(@criteria, "bugs.product_id = $product_id");
push(@excluded_columns, 'product'); push(@excluded_columns, 'product') unless $::FORM{'do_union'};
if (defined($::FORM{'component'}) && $::FORM{'component'} ne "") { if (defined($::FORM{'component'}) && $::FORM{'component'} ne "") {
my $component_id = get_component_id($product_id, $::FORM{'component'}); my $component_id = get_component_id($product_id, $::FORM{'component'});
if ($component_id) { if ($component_id) {
$query .= " AND bugs.component_id = $component_id"; push(@criteria, "bugs.component_id = $component_id");
push(@excluded_columns, 'component'); push(@excluded_columns, 'component') unless $::FORM{'do_union'};
} }
else { ThrowCodeError("unknown_component", { %::FORM }) } else { ThrowCodeError("unknown_component", { %::FORM }) }
} }
...@@ -177,10 +185,16 @@ sub queue { ...@@ -177,10 +185,16 @@ sub queue {
} }
if (!$has_attachment_type) { push(@excluded_columns, 'attachment') } if (!$has_attachment_type) { push(@excluded_columns, 'attachment') }
$query .= " AND flagtypes.name = " . SqlQuote($::FORM{'type'}); push(@criteria, "flagtypes.name = " . SqlQuote($::FORM{'type'}));
push(@excluded_columns, 'type'); push(@excluded_columns, 'type') unless $::FORM{'do_union'};
} }
# Add the criteria to the query. We do an intersection by default
# but do a union if the "do_union" URL parameter (for which there is no UI
# because it's an advanced feature that people won't usually want) is true.
my $and_or = $::FORM{'do_union'} ? " OR " : " AND ";
$query .= " AND (" . join($and_or, @criteria) . ") " if scalar(@criteria);
# Group the records by flag ID so we don't get multiple rows of data # Group the records by flag ID so we don't get multiple rows of data
# for each flag. This is only necessary because of the code that # for each flag. This is only necessary because of the code that
# removes flags on bugs the user is unauthorized to access. # removes flags on bugs the user is unauthorized to access.
...@@ -209,6 +223,7 @@ sub queue { ...@@ -209,6 +223,7 @@ sub queue {
# Pass the query to the template for use when debugging this script. # Pass the query to the template for use when debugging this script.
$vars->{'query'} = $query; $vars->{'query'} = $query;
$vars->{'debug'} = $::FORM{'debug'} ? 1 : 0;
SendSQL($query); SendSQL($query);
my @requests = (); my @requests = ();
......
...@@ -51,8 +51,13 @@ ...@@ -51,8 +51,13 @@
<a href="report.cgi">Reports</a> <a href="report.cgi">Reports</a>
| <a href="request.cgi">Requests</a> [% IF user.login %]
[% email = user.login FILTER url_quote %]
| <a href="request.cgi?requester=[% email %]&requestee=[% email %]&do_union=1&group=type">My Requests</a>
[% ELSE %]
| <a href="request.cgi">Requests</a>
[% END %]
[% IF user.login && Param('usevotes') %] [% IF user.login && Param('usevotes') %]
| <a href="votes.cgi?action=show_user">My Votes</a> | <a href="votes.cgi?action=show_user">My Votes</a>
[% END %] [% END %]
......
...@@ -103,15 +103,6 @@ ...@@ -103,15 +103,6 @@
</form> </form>
[% END %] [% END %]
[% PROCESS global/header.html.tmpl
title="Request Queue"
h2=filter_form
style = "
table.requests th { text-align: left; }
table#filter th { text-align: right; }
"
%]
[% column_headers = { [% column_headers = {
"type" => "Flag" , "type" => "Flag" ,
"status" => "Status" , "status" => "Status" ,
...@@ -128,6 +119,19 @@ ...@@ -128,6 +119,19 @@
%] %]
[% PROCESS global/header.html.tmpl
title="Request Queue"
h2=filter_form
style = "
table.requests th { text-align: left; }
table#filter th { text-align: right; }
"
%]
[% IF debug %]
<p>[% query FILTER html %]</p>
[% END %]
[% IF requests.size == 0 %] [% IF requests.size == 0 %]
<p> <p>
No requests. No requests.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment