Commit 61898d18 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 199048: Preference option to reverse sort the comments stack - Patch by…

Bug 199048: Preference option to reverse sort the comments stack - Patch by Shane H. W. Travis <shane.h.w.travis@gmail.com> r=mkanat a=myk
parent 940a96d6
...@@ -761,7 +761,11 @@ sub ValidateTime { ...@@ -761,7 +761,11 @@ sub ValidateTime {
} }
sub GetComments { sub GetComments {
my ($id) = (@_); my ($id, $comment_sort_order) = (@_);
$comment_sort_order = $comment_sort_order ||
Bugzilla->user->settings->{'comment_sort_order'}->{'value'};
my $sort_order = ($comment_sort_order eq "oldest_to_newest") ? 'asc' : 'desc';
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my @comments; my @comments;
my $sth = $dbh->prepare( my $sth = $dbh->prepare(
...@@ -774,7 +778,7 @@ sub GetComments { ...@@ -774,7 +778,7 @@ sub GetComments {
FROM longdescs, profiles FROM longdescs, profiles
WHERE profiles.userid = longdescs.who WHERE profiles.userid = longdescs.who
AND longdescs.bug_id = ? AND longdescs.bug_id = ?
ORDER BY longdescs.bug_when"); ORDER BY longdescs.bug_when $sort_order");
$sth->execute($id); $sth->execute($id);
while (my $comment_ref = $sth->fetchrow_hashref()) { while (my $comment_ref = $sth->fetchrow_hashref()) {
...@@ -789,6 +793,10 @@ sub GetComments { ...@@ -789,6 +793,10 @@ sub GetComments {
push (@comments, \%comment); push (@comments, \%comment);
} }
if ($comment_sort_order eq "newest_to_oldest_desc_first") {
unshift(@comments, pop @comments);
}
return \@comments; return \@comments;
} }
......
...@@ -3953,6 +3953,13 @@ if ($dbh->bz_get_field_def('quips', 'approved')->[1] eq 'tinyint(1)') { ...@@ -3953,6 +3953,13 @@ if ($dbh->bz_get_field_def('quips', 'approved')->[1] eq 'tinyint(1)') {
'tinyint not null default 1'); 'tinyint not null default 1');
} }
# 2005-03-10 travis@sedsystems.ca -- Bug 199048
add_setting ("comment_sort_order", {"oldest_to_newest" => 1,
"newest_to_oldest" => 2,
"newest_to_oldest_desc_first" => 3},
"oldest_to_newest" );
} # END LEGACY CHECKS } # END LEGACY CHECKS
# If you had to change the --TABLE-- definition in any way, then add your # If you had to change the --TABLE-- definition in any way, then add your
......
...@@ -1334,7 +1334,10 @@ foreach my $id (@idlist) { ...@@ -1334,7 +1334,10 @@ foreach my $id (@idlist) {
$cgi->param('delta_ts')); $cgi->param('delta_ts'));
$vars->{'start_at'} = $cgi->param('longdesclength'); $vars->{'start_at'} = $cgi->param('longdesclength');
$vars->{'comments'} = Bugzilla::Bug::GetComments($id);
# Always sort midair collision comments oldest to newest,
# regardless of the user's personal preference.
$vars->{'comments'} = Bugzilla::Bug::GetComments($id, "oldest_to_newest");
$cgi->param('delta_ts', $delta_ts); $cgi->param('delta_ts', $delta_ts);
......
...@@ -18,21 +18,48 @@ ...@@ -18,21 +18,48 @@
# #
# Contributor(s): Gervase Markham <gerv@gerv.net> # Contributor(s): Gervase Markham <gerv@gerv.net>
# Maxwell Kanat-Alexander <mkanat@kerio.com> # Maxwell Kanat-Alexander <mkanat@kerio.com>
# Shane H. W. Travis <travis@sedsystems.ca>
#%] #%]
[% PROCESS bug/time.html.tmpl %]
[% DEFAULT start_at = 0 mode = "show" %] [% DEFAULT start_at = 0 mode = "show" %]
[% count = 0 %]
[% isinsider = Param("insidergroup") && UserInGroup(Param("insidergroup")) %] [% isinsider = Param("insidergroup") && UserInGroup(Param("insidergroup")) %]
[% sort_order = user.settings.comment_sort_order.value %]
[%# NOTE: (start_at > 0) means we came here from a midair collision,
# in which case we don't care what the user's preference is.
%]
[% IF (start_at > 0) %]
[% sort_order = "oldest_to_newest" %]
[% END %]
[%# Set up the variables as needed, depending on the sort order %]
[% IF sort_order == "oldest_to_newest" %]
[% count = 0 %]
[% description = 0 %]
[% increment = 1 %]
[% ELSE %]
[% increment = -1 %]
[% IF sort_order == "newest_to_oldest" %]
[% count = comments.size - 1 %]
[% description = 0 %]
[% ELSIF sort_order == "newest_to_oldest_desc_first" %]
[% count = comments.size %]
[% description = comments.size %]
[% END %]
[% END %]
[% FOREACH comment = comments %] [% FOREACH comment = comments %]
[% IF count >= start_at %] [% IF count >= start_at %]
[% PROCESS a_comment %] [% PROCESS a_comment %]
[% END %] [% END %]
[% count = count + 1 %] [% count = count + increment %]
[% END %] [% END %]
[% PROCESS bug/time.html.tmpl %]
[%# Note: this template is used in multiple places; if you use this hook, [%# Note: this template is used in multiple places; if you use this hook,
# make sure you are aware of this fact. # make sure you are aware of this fact.
#%] #%]
...@@ -46,7 +73,21 @@ ...@@ -46,7 +73,21 @@
[% IF NOT comment.isprivate || isinsider %] [% IF NOT comment.isprivate || isinsider %]
<div [% "class=\"bz_private\" " IF comment.isprivate %] <div [% "class=\"bz_private\" " IF comment.isprivate %]
[% "class=\"bz_comment_hilite\" " IF marks.$count %]> [% "class=\"bz_comment_hilite\" " IF marks.$count %]>
[% IF count > 0 %] [% IF count == description %]
<table>
<tr>
<td align="left">
<b><a name="c0" href="#c0">Description</a>:</b>&nbsp;&nbsp;<script
type="text/javascript"><!--
addReplyLink(0);
//--></script>
</td>
<td align="left" width="30%">
Opened: [% bug.creation_ts FILTER time %]
</td>
</tr>
</table>
[% ELSE %]
<br> <br>
<span class="bz_comment"> <span class="bz_comment">
------- <i>Comment ------- <i>Comment
......
...@@ -566,19 +566,6 @@ ...@@ -566,19 +566,6 @@
[%# *** Additional Comments *** %] [%# *** Additional Comments *** %]
<hr> <hr>
<table>
<tr>
<td align="left">
<b><a name="c0" href="#c0">Description</a>:</b>&nbsp;&nbsp;<script
type="text/javascript"><!--
addReplyLink(0);
//--></script>
</td>
<td align="right" width="100%">
Opened: [% bug.creation_ts FILTER time %]
</td>
</tr>
</table>
[% PROCESS bug/comments.html.tmpl [% PROCESS bug/comments.html.tmpl
comments = bug.longdescs comments = bug.longdescs
......
...@@ -20,8 +20,12 @@ ...@@ -20,8 +20,12 @@
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% setting_descs = { [% setting_descs = {
"display_quips" => "Show a quip at the top of each bug list", "comment_sort_order" => "When viewing $terms.abug, show comments in this order",
"off" => "Off", "display_quips" => "Show a quip at the top of each bug list",
"on" => "On" "newest_to_oldest" => "Newest to Oldest",
"newest_to_oldest_desc_first" => "Newest to Oldest, but keep Description at the top",
"off" => "Off",
"oldest_to_newest" => "Oldest to Newest",
"on" => "On"
} }
%] %]
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