summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorwurblzap%gmail.com <>2009-06-03 00:00:10 +0200
committerwurblzap%gmail.com <>2009-06-03 00:00:10 +0200
commit5a10ebe6514918f89e60e0dc43fa19ebe06c03be (patch)
treed2c2a8ecb05804f93e69fd79d58993d57f155258 /Bugzilla
parenta778b485e088757d81606ff85aae2f39473c42f5 (diff)
downloadbugzilla-5a10ebe6514918f89e60e0dc43fa19ebe06c03be.tar.gz
bugzilla-5a10ebe6514918f89e60e0dc43fa19ebe06c03be.tar.xz
Bug 457657 – Make e-mail comment header localizable.
Patch by Marc Schumann <wurblzap@gmail.com>, r/a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm24
-rw-r--r--Bugzilla/BugMail.pm48
-rw-r--r--Bugzilla/User.pm7
3 files changed, 19 insertions, 60 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;
}