diff options
author | wurblzap%gmail.com <> | 2009-06-02 22:00:10 +0000 |
---|---|---|
committer | wurblzap%gmail.com <> | 2009-06-02 22:00:10 +0000 |
commit | 5a10ebe6514918f89e60e0dc43fa19ebe06c03be (patch) | |
tree | d2c2a8ecb05804f93e69fd79d58993d57f155258 | |
parent | a778b485e088757d81606ff85aae2f39473c42f5 (diff) | |
download | bugs-5a10ebe6514918f89e60e0dc43fa19ebe06c03be.tar bugs-5a10ebe6514918f89e60e0dc43fa19ebe06c03be.tar.gz bugs-5a10ebe6514918f89e60e0dc43fa19ebe06c03be.tar.bz2 bugs-5a10ebe6514918f89e60e0dc43fa19ebe06c03be.tar.xz bugs-5a10ebe6514918f89e60e0dc43fa19ebe06c03be.zip |
Bug 457657 â Make e-mail comment header localizable.
Patch by Marc Schumann <wurblzap@gmail.com>,
r/a=LpSolit
-rw-r--r-- | Bugzilla/Bug.pm | 24 | ||||
-rw-r--r-- | Bugzilla/BugMail.pm | 48 | ||||
-rw-r--r-- | Bugzilla/User.pm | 7 | ||||
-rwxr-xr-x | template/en/default/bug/format_comment.txt.tmpl | 61 | ||||
-rw-r--r-- | template/en/default/email/newchangedmail.txt.tmpl | 7 | ||||
-rw-r--r-- | template/en/default/global/messages.html.tmpl | 16 |
6 files changed, 86 insertions, 77 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 79cf1dd5e..f1fc9c424 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -3060,29 +3060,15 @@ sub GetComments { return \@comments; } -# Format language specific comments. This routine must not update -# $comment{'body'} itself, see BugMail::prepare_comments(). +# Format language specific comments. sub format_comment { my $comment = shift; + my $template = Bugzilla->template_inner; + my $vars = {comment => $comment}; my $body; - if ($comment->{'type'} == CMT_DUPE_OF) { - $body = $comment->{'body'} . "\n\n" . - get_text('bug_duplicate_of', { dupe_of => $comment->{'extra_data'} }); - } - elsif ($comment->{'type'} == CMT_HAS_DUPE) { - $body = get_text('bug_has_duplicate', { dupe => $comment->{'extra_data'} }); - } - elsif ($comment->{'type'} == CMT_POPULAR_VOTES) { - $body = get_text('bug_confirmed_by_votes'); - } - elsif ($comment->{'type'} == CMT_MOVED_TO) { - $body = $comment->{'body'} . "\n\n" . - get_text('bug_moved_to', { login => $comment->{'extra_data'} }); - } - else { - $body = $comment->{'body'}; - } + $template->process("bug/format_comment.txt.tmpl", $vars, \$body) + || ThrowTemplateError($template->error()); return $body; } diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index 9f7b2e753..9a1b2a8a2 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -357,7 +357,7 @@ sub Send { } } - my ($raw_comments, $anyprivate, $count) = get_comments_by_bug($id, $start, $end); + my ($comments, $anyprivate) = get_comments_by_bug($id, $start, $end); ########################################################################### # Start of email filtering code @@ -450,9 +450,6 @@ sub Send { my @sent; my @excluded; - # Some comments are language specific. We cache them here. - my %comments; - foreach my $user_id (keys %recipients) { my %rels_which_want; my $sent_mail = 0; @@ -461,24 +458,14 @@ sub Send { # Deleted users must be excluded. next unless $user; - # What's the language chosen by this user for email? - my $lang = $user->settings->{'lang'}->{'value'}; - if ($user->can_see_bug($id)) { - # It's time to format language specific comments. - unless (exists $comments{$lang}) { - Bugzilla->template_inner($lang); - $comments{$lang} = prepare_comments($raw_comments, $count); - Bugzilla->template_inner(""); - } - # Go through each role the user has and see if they want mail in # that role. foreach my $relationship (keys %{$recipients{$user_id}}) { if ($user->wants_bug_mail($id, $relationship, $diffs, - $comments{$lang}, + $comments, $deptext, $changer, !$start)) @@ -524,7 +511,7 @@ sub Send { \%defmailhead, \%fielddescription, \@diffparts, - $comments{$lang}, + $comments, $anyprivate, ! $start, $id, @@ -607,7 +594,7 @@ sub sendMail { $newcomments =~ s/(Created an attachment \(id=([0-9]+)\))/$1\n --> \(${showattachurlbase}$2\)/g; } - my $diffs = $difftext . "\n\n" . $newcomments; + my $diffs = $difftext; if ($isnew) { my $head = ""; foreach my $f (@headerlist) { @@ -663,6 +650,7 @@ sub sendMail { reporter => $values{'reporter'}, reportername => Bugzilla::User->new({name => $values{'reporter'}})->name, diffs => $diffs, + new_comments => $newcomments, threadingmarker => build_thread_marker($id, $user->id, $isnew), }; @@ -698,31 +686,15 @@ sub get_comments_by_bug { my $raw = 1; # Do not format comments which are not of type CMT_NORMAL. my $comments = Bugzilla::Bug::GetComments($id, "oldest_to_newest", $start, $end, $raw); + foreach my $comment (@$comments) { + $comment->{count} = $count++; + } + if (Bugzilla->params->{'insidergroup'}) { $anyprivate = 1 if scalar(grep {$_->{'isprivate'} > 0} @$comments); } - return ($comments, $anyprivate, $count); -} - -# Prepare comments for the given language. -sub prepare_comments { - my ($raw_comments, $count) = @_; - - my $result = ""; - foreach my $comment (@$raw_comments) { - if ($count) { - $result .= "\n\n--- Comment #$count from " . $comment->{'author'}->identity . - " " . format_time($comment->{'time'}) . " ---\n"; - } - # Format language specific comments. We don't update $comment->{'body'} - # directly, otherwise it would grow everytime you call format_comment() - # with a different language as some text may be appended to the existing one. - my $body = Bugzilla::Bug::format_comment($comment); - $result .= ($comment->{'already_wrapped'} ? $body : wrap_comment($body)); - $count++; - } - return $result; + return ($comments, $anyprivate); } 1; diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 55be2cf9e..0eb47b8b3 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -1372,8 +1372,9 @@ our %names_to_events = ( # Note: the "+" signs before the constants suppress bareword quoting. sub wants_bug_mail { my $self = shift; - my ($bug_id, $relationship, $fieldDiffs, $commentField, $dependencyText, + my ($bug_id, $relationship, $fieldDiffs, $comments, $dependencyText, $changer, $bug_is_new) = @_; + my $comments_concatenated = join("\n", map { $_->{body} } (@$comments)); # Make a list of the events which have happened during this bug change, # from the point of view of this user. @@ -1422,10 +1423,10 @@ sub wants_bug_mail { } } - if ($commentField =~ /Created an attachment \(/) { + if ($comments_concatenated =~ /Created an attachment \(/) { $events{+EVT_ATTACHMENT} = 1; } - elsif ($commentField ne '') { + elsif (defined($$comments[0])) { $events{+EVT_COMMENT} = 1; } diff --git a/template/en/default/bug/format_comment.txt.tmpl b/template/en/default/bug/format_comment.txt.tmpl new file mode 100755 index 000000000..6da39e6eb --- /dev/null +++ b/template/en/default/bug/format_comment.txt.tmpl @@ -0,0 +1,61 @@ +[%# The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Bug Tracking System. + # + # The Initial Developer of the Original Code is Marc Schumann. + # Portions created by Marc Schumann are Copyright (c) 2008 Marc Schumann. + # All rights reserved. + # + # Contributor(s): Marc Schumann <wurblzap@gmail.com> + #%] + +[%# INTERFACE: + # comment: A hash containing comment information. + # count: The comment number (on the bug it belongs to) + # author: The Bugzilla::User object of the comment's + # author + # time: The time at which the comment has been + # committed + # body: The comment text + # type: One of the CMT_* constants (not given if none + # applies) + # extra_data: Extra data (type specific) + # already_wrapped: Determines whether the comment is pre-wrapped + #%] + +[% PROCESS 'global/field-descs.none.tmpl' %] + +[% IF comment.already_wrapped %] + [% wrapped_comment = comment.body %] +[% ELSE %] + [% wrapped_comment = comment.body FILTER wrap_comment %] +[% END %] + +[%- IF comment.type == constants.CMT_DUPE_OF -%] +[% wrapped_comment %] + +*** This [% terms.bug %] has been marked as a duplicate of [% terms.bug %] [%+ comment.extra_data %] *** +[% ELSIF comment.type == constants.CMT_HAS_DUPE %] +*** [% terms.Bug %] [%+ comment.extra_data %] has been marked as a duplicate of this [% terms.bug %]. *** +[% ELSIF comment.type == constants.CMT_POPULAR_VOTES %] +*** This [% terms.bug %] has been confirmed by popular vote. *** +[% ELSIF comment.type == constants.CMT_MOVED_TO %] +[% wrapped_comment %] + +[%+ terms.Bug %] moved to [% Param("move-to-url") %]. +If the move succeeded, [% comment.extra_data %] will receive a mail containing +the number of the new [% terms.bug %] in the other database. +If all went well, please mark this [% terms.bug %] +[%+ get_status('VERIFIED') %], and paste in a link to the new [% terms.bug %]. +Otherwise, reopen this [% terms.bug %]. +[%- ELSE -%] +[%- wrapped_comment %] +[% END %] diff --git a/template/en/default/email/newchangedmail.txt.tmpl b/template/en/default/email/newchangedmail.txt.tmpl index 613e174f0..494c12060 100644 --- a/template/en/default/email/newchangedmail.txt.tmpl +++ b/template/en/default/email/newchangedmail.txt.tmpl @@ -43,8 +43,13 @@ X-Bugzilla-Changed-Fields: [% changedfields %] [%+ urlbase %]show_bug.cgi?id=[% bugid %] [%+ diffs %] +[% FOREACH comment = new_comments %] --- +--- Comment #[% comment.count %] from [% comment.author.identity %] [%+ comment.time FILTER time %] --- +[%+ PROCESS bug/format_comment.txt.tmpl comment = comment %] +[% END %] + +-- [%# Protect the trailing space of the signature marker %] Configure [% terms.bug %]mail: [% urlbase %]userprefs.cgi?tab=email ------- You are receiving this mail because: ------- [% FOREACH relationship = reasons %] diff --git a/template/en/default/global/messages.html.tmpl b/template/en/default/global/messages.html.tmpl index 1bc10daa9..c29f3f14f 100644 --- a/template/en/default/global/messages.html.tmpl +++ b/template/en/default/global/messages.html.tmpl @@ -124,25 +124,9 @@ Please add your attachment by clicking the "Add an Attachment" link below. - [% ELSIF message_tag == "bug_confirmed_by_votes" %] - *** This [% terms.bug %] has been confirmed by popular vote. *** - - [% ELSIF message_tag == "bug_duplicate_of" %] - *** This [% terms.bug %] has been marked as a duplicate of [% terms.bug %] [%+ dupe_of FILTER html %] *** - - [% ELSIF message_tag == "bug_has_duplicate" %] - *** [% terms.Bug %] [%+ dupe FILTER html %] has been marked as a duplicate of this [% terms.bug %]. *** - [% ELSIF message_tag == "bug_group_description" %] Access to [% terms.bugs %] in the [% product.name FILTER html %] product - [% ELSIF message_tag == "bug_moved_to" %] - <p>[% terms.Bug %] moved to [% Param("move-to-url") FILTER html %].</p> - <p>If the move succeeded, [% login FILTER html %] will receive a mail - containing the number of the new [% terms.bug %] in the other database. - If all went well, please mark this [% terms.bug %] verified, and paste - in a link to the new [% terms.bug %]. Otherwise, reopen this [% terms.bug %]. - [% ELSIF message_tag == "buglist_adding_field" %] [% title = "Adding field to search page..." %] [% link = "Click here if the page does not redisplay automatically." %] |