From: lpsolit%gmail.com <> Date: Sat, 9 Apr 2005 07:37:50 +0000 (+0000) Subject: Bug 199048: Preference option to reverse sort the comments stack - Patch by Shane... X-Git-Tag: bugzilla-2.19.3~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61898d18479013cfbcc820ff25f39377db071536;p=thirdparty%2Fbugzilla.git Bug 199048: Preference option to reverse sort the comments stack - Patch by Shane H. W. Travis r=mkanat a=myk --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 5017196b3d..8accc452c9 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -761,7 +761,11 @@ sub ValidateTime { } 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 @comments; my $sth = $dbh->prepare( @@ -774,7 +778,7 @@ sub GetComments { FROM longdescs, profiles WHERE profiles.userid = longdescs.who AND longdescs.bug_id = ? - ORDER BY longdescs.bug_when"); + ORDER BY longdescs.bug_when $sort_order"); $sth->execute($id); while (my $comment_ref = $sth->fetchrow_hashref()) { @@ -789,6 +793,10 @@ sub GetComments { push (@comments, \%comment); } + + if ($comment_sort_order eq "newest_to_oldest_desc_first") { + unshift(@comments, pop @comments); + } return \@comments; } diff --git a/checksetup.pl b/checksetup.pl index 44930ae732..ce9278f05a 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -3953,6 +3953,13 @@ if ($dbh->bz_get_field_def('quips', 'approved')->[1] eq 'tinyint(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 # If you had to change the --TABLE-- definition in any way, then add your diff --git a/process_bug.cgi b/process_bug.cgi index e7d2de104a..f85fd45d63 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -1334,7 +1334,10 @@ foreach my $id (@idlist) { $cgi->param('delta_ts')); $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); diff --git a/template/en/default/bug/comments.html.tmpl b/template/en/default/bug/comments.html.tmpl index 7a9dfb4efe..58eaa376c2 100644 --- a/template/en/default/bug/comments.html.tmpl +++ b/template/en/default/bug/comments.html.tmpl @@ -18,21 +18,48 @@ # # Contributor(s): Gervase Markham # Maxwell Kanat-Alexander + # Shane H. W. Travis #%] +[% PROCESS bug/time.html.tmpl %] + [% DEFAULT start_at = 0 mode = "show" %] -[% count = 0 %] [% 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 %] [% IF count >= start_at %] [% PROCESS a_comment %] [% END %] - [% count = count + 1 %] + [% count = count + increment %] [% END %] -[% PROCESS bug/time.html.tmpl %] - [%# Note: this template is used in multiple places; if you use this hook, # make sure you are aware of this fact. #%] @@ -46,7 +73,21 @@ [% IF NOT comment.isprivate || isinsider %]
- [% IF count > 0 %] + [% IF count == description %] + + + + + +
+ Description:   + + Opened: [% bug.creation_ts FILTER time %] +
+ [% ELSE %]
------- Comment diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl index 86fb4c6b63..d15cf91026 100644 --- a/template/en/default/bug/edit.html.tmpl +++ b/template/en/default/bug/edit.html.tmpl @@ -566,19 +566,6 @@ [%# *** Additional Comments *** %]
- - - - - -
- Description:   - - Opened: [% bug.creation_ts FILTER time %] -
[% PROCESS bug/comments.html.tmpl comments = bug.longdescs diff --git a/template/en/default/global/setting-descs.none.tmpl b/template/en/default/global/setting-descs.none.tmpl index 9e7ac95966..1a31754a8e 100644 --- a/template/en/default/global/setting-descs.none.tmpl +++ b/template/en/default/global/setting-descs.none.tmpl @@ -20,8 +20,12 @@ [% PROCESS global/variables.none.tmpl %] [% setting_descs = { - "display_quips" => "Show a quip at the top of each bug list", - "off" => "Off", - "on" => "On" + "comment_sort_order" => "When viewing $terms.abug, show comments in this order", + "display_quips" => "Show a quip at the top of each bug list", + "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" } %]