Commit 7d00b5f6 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 23473: Implement the ability to reverse the sort order in buglist.cgi…

Bug 23473: Implement the ability to reverse the sort order in buglist.cgi ("Ascending" and "Descending") - Patch by Alex Schuilenburg <alex@schuilenburg.org> r/a=LpSolit
parent 16a1c874
...@@ -78,7 +78,7 @@ sub REQUIRED_MODULES { ...@@ -78,7 +78,7 @@ sub REQUIRED_MODULES {
{ {
package => 'Template-Toolkit', package => 'Template-Toolkit',
module => 'Template', module => 'Template',
version => '2.12' version => '2.15'
}, },
{ {
package => 'Email-Send', package => 'Email-Send',
......
...@@ -873,6 +873,7 @@ if ($order) { ...@@ -873,6 +873,7 @@ if ($order) {
# A custom list of columns. Make sure each column is valid. # A custom list of columns. Make sure each column is valid.
foreach my $fragment (split(/,/, $order)) { foreach my $fragment (split(/,/, $order)) {
$fragment = trim($fragment); $fragment = trim($fragment);
next unless $fragment;
# Accept an order fragment matching a column name, with # Accept an order fragment matching a column name, with
# asc|desc optionally following (to specify the direction) # asc|desc optionally following (to specify the direction)
if (grep($fragment =~ /^\Q$_\E(\s+(asc|desc))?$/, @columnnames, keys(%$columns))) { if (grep($fragment =~ /^\Q$_\E(\s+(asc|desc))?$/, @columnnames, keys(%$columns))) {
...@@ -893,11 +894,12 @@ if ($order) { ...@@ -893,11 +894,12 @@ if ($order) {
$order = join(",", @order); $order = join(",", @order);
# Now that we have checked that all columns in the order are valid, # Now that we have checked that all columns in the order are valid,
# detaint the order string. # detaint the order string.
trick_taint($order); trick_taint($order) if $order;
}; };
} }
} }
else {
if (!$order) {
# DEFAULT # DEFAULT
$order = "bugs.bug_status, bugs.priority, map_assigned_to.login_name, bugs.bug_id"; $order = "bugs.bug_status, bugs.priority, map_assigned_to.login_name, bugs.bug_id";
} }
......
...@@ -88,8 +88,12 @@ ...@@ -88,8 +88,12 @@
[% IF sorted_by_relevance %] [% IF sorted_by_relevance %]
ID ID
[% ELSE %] [% ELSE %]
[% desc = '' %]
[% IF (om = order.match("^bugs\.bug_id( desc)?")) %]
[% desc = ' desc' IF NOT om.0 %]
[% END %]
<a href="buglist.cgi? <a href="buglist.cgi?
[% urlquerypart FILTER html %]&amp;order=bugs.bug_id [% urlquerypart FILTER html %]&amp;order=bugs.bug_id[% desc FILTER url_quote %]
[%-#%]&amp;query_based_on= [%-#%]&amp;query_based_on=
[% defaultsavename OR searchname FILTER url_quote %]">ID</a> [% defaultsavename OR searchname FILTER url_quote %]">ID</a>
[% END %] [% END %]
...@@ -139,8 +143,13 @@ ...@@ -139,8 +143,13 @@
[%# Other columns may sort on their name directly. %] [%# Other columns may sort on their name directly. %]
[% column.sortalias = column.name %] [% column.sortalias = column.name %]
[% END %] [% END %]
[% desc = '' %]
[% IF (om = order.match("$column.sortalias( desc)?")) %]
[% desc = ' desc' IF NOT om.0 %]
[% END %]
[% order = order.remove("$column.sortalias( desc)?,?") %]
<a href="buglist.cgi?[% urlquerypart FILTER html %]&amp;order= <a href="buglist.cgi?[% urlquerypart FILTER html %]&amp;order=
[% column.sortalias FILTER url_quote %] [% column.sortalias FILTER url_quote %][% desc FILTER url_quote %]
[% ",$order" FILTER url_quote IF order %] [% ",$order" FILTER url_quote IF order %]
[%-#%]&amp;query_based_on= [%-#%]&amp;query_based_on=
[% defaultsavename OR searchname FILTER url_quote %]"> [% defaultsavename OR searchname FILTER url_quote %]">
......
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