summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2006-08-15 04:45:15 +0200
committerlpsolit%gmail.com <>2006-08-15 04:45:15 +0200
commit54641d0e624239fdbe1c9e6dc724b977f2aeebbb (patch)
treed61d82e7e7e12d04a65df74fbf508d98c908b702
parent10ece7637657f06eea27bb1ab06da35ca8a78765 (diff)
downloadbugzilla-54641d0e624239fdbe1c9e6dc724b977f2aeebbb.tar.gz
bugzilla-54641d0e624239fdbe1c9e6dc724b977f2aeebbb.tar.xz
Bug 275636: Templatise 'newchangedmail' email (BugMail) - Patch by André Batosti <batosti@async.com.br> r=LpSolit a=myk
-rw-r--r--Bugzilla/BugMail.pm67
-rw-r--r--Bugzilla/Config/MTA.pm29
-rw-r--r--t/009bugwords.t2
-rw-r--r--template/en/default/admin/params/mta.html.tmpl19
-rw-r--r--template/en/default/email/newchangedmail.txt.tmpl47
5 files changed, 83 insertions, 81 deletions
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 98a8e92bf..4221a9dc4 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -580,8 +580,6 @@ sub sendMail {
my $isnew = !$start;
- my %substs;
-
# If an attachment was created, then add an URL. (Note: the 'g'lobal
# replace should work with comments with multiple attachments.)
@@ -593,25 +591,13 @@ sub sendMail {
$newcomments =~ s/(Created an attachment \(id=([0-9]+)\))/$1\n --> \(${showattachurlbase}$2\)/g;
}
- $substs{"neworchanged"} = $isnew ? 'New: ' : '';
- $substs{"to"} = $user->email;
- $substs{"cc"} = '';
- $substs{"bugid"} = $id;
+ my $diffs;
if ($isnew) {
- $substs{"diffs"} = $head . "\n\n" . $newcomments;
+ $diffs = $head . "\n\n" . $newcomments;
} else {
- $substs{"diffs"} = $difftext . "\n\n" . $newcomments;
+ $diffs = $difftext . "\n\n" . $newcomments;
}
- $substs{"product"} = $values{'product'};
- $substs{"component"} = $values{'component'};
- $substs{"keywords"} = $values{'keywords'};
- $substs{"severity"} = $values{'bug_severity'};
- $substs{"status"} = $values{'bug_status'};
- $substs{"priority"} = $values{'priority'};
- $substs{"assignedto"} = $values{'assigned_to'};
- $substs{"targetmilestone"} = $values{'target_milestone'};
- $substs{"changedfields"} = $values{'changed_fields'};
- $substs{"summary"} = $values{'short_desc'};
+
my (@headerrel, @watchingrel);
while (my ($rel, $bits) = each %{$relRef}) {
push @headerrel, (REL_NAMES->{$rel}) if ($bits & BIT_DIRECT);
@@ -620,13 +606,6 @@ sub sendMail {
push @headerrel, 'None' if !scalar(@headerrel);
push @watchingrel, 'None' if !scalar(@watchingrel);
push @watchingrel, map { user_id_to_login($_) } @$watchingRef;
- $substs{"reasonsheader"} = join(" ", @headerrel);
- $substs{"reasonswatchheader"} = join(" ", @watchingrel);
-
- $substs{"reasonsbody"} = $reasonsbody;
- $substs{"space"} = " ";
- $substs{"changer"} = $values{'changer'};
- $substs{"changername"} = $values{'changername'};
my $sitespec = '@' . Bugzilla->params->{'urlbase'};
$sitespec =~ s/:\/\//\./; # Make the protocol look like part of the domain
@@ -634,17 +613,41 @@ sub sendMail {
if ($2) {
$sitespec = "-$2$sitespec"; # Put the port number back in, before the '@'
}
+ my $threadingmarker;
if ($isnew) {
- $substs{'threadingmarker'} = "Message-ID: <bug-$id-" .
- $user->id . "$sitespec>";
+ $threadingmarker = "Message-ID: <bug-$id-" . $user->id . "$sitespec>";
} else {
- $substs{'threadingmarker'} = "In-Reply-To: <bug-$id-" .
- $user->id . "$sitespec>";
+ $threadingmarker = "In-Reply-To: <bug-$id-" . $user->id . "$sitespec>";
}
- my $template = Bugzilla->params->{"newchangedmail"};
-
- my $msg = perform_substs($template, \%substs);
+
+ my $vars = {
+ neworchanged => $isnew ? 'New: ' : '',
+ to => $user->email,
+ bugid => $id,
+ product => $values{'product'},
+ comp => $values{'component'},
+ keywords => $values{'keywords'},
+ severity => $values{'bug_severity'},
+ status => $values{'bug_status'},
+ priority => $values{'priority'},
+ assignedto => $values{'assigned_to'},
+ targetmilestone => $values{'target_milestone'},
+ changedfields => $values{'changed_fields'},
+ summary => $values{'short_desc'},
+ reasonsheader => join(" ", @headerrel),
+ reasonswatchheader => join(" ", @watchingrel),
+ reasonsbody => $reasonsbody,
+ changer => $values{'changer'},
+ changername => $values{'changername'},
+ diffs => $diffs,
+ threadingmarker => $threadingmarker
+ };
+
+ my $msg;
+ my $template = Bugzilla::Template->create();
+ $template->process("email/newchangedmail.txt.tmpl", $vars, \$msg)
+ || ThrowTemplateError($template->error());
MessageToMTA($msg);
diff --git a/Bugzilla/Config/MTA.pm b/Bugzilla/Config/MTA.pm
index 474160a72..4364db49b 100644
--- a/Bugzilla/Config/MTA.pm
+++ b/Bugzilla/Config/MTA.pm
@@ -63,35 +63,6 @@ sub get_param_list {
},
{
- name => 'newchangedmail',
- type => 'l',
- default => 'From: bugzilla-daemon
-To: %to%
-Subject: [Bug %bugid%] %neworchanged%%summary%
-%threadingmarker%
-X-Bugzilla-Reason: %reasonsheader%
-X-Bugzilla-Watch-Reason: %reasonswatchheader%
-X-Bugzilla-Product: %product%
-X-Bugzilla-Component: %component%
-X-Bugzilla-Keywords: %keywords%
-X-Bugzilla-Severity: %severity%
-X-Bugzilla-Who: %changer%
-X-Bugzilla-Status: %status%
-X-Bugzilla-Priority: %priority%
-X-Bugzilla-Assigned-To: %assignedto%
-X-Bugzilla-Target-Milestone: %targetmilestone%
-X-Bugzilla-Changed-Fields: %changedfields%
-
-%urlbase%show_bug.cgi?id=%bugid%
-
-%diffs%
-
---%space%
-Configure bugmail: %urlbase%userprefs.cgi?tab=email
-%reasonsbody%'
- },
-
- {
name => 'whinedays',
type => 't',
default => 7,
diff --git a/t/009bugwords.t b/t/009bugwords.t
index 9249ba4ac..5b1a9d6ba 100644
--- a/t/009bugwords.t
+++ b/t/009bugwords.t
@@ -77,7 +77,7 @@ foreach my $file (@testitems) {
}
# "Bugzilla"
- if (grep /Bugzilla[^_]/, $text) {
+ if (grep /(?<!X\-)Bugzilla(?!_)/, $text) {
# Exclude JS comments, hyperlinks, USE and variable assignment.
unless (grep /(\/\/.*|org.*>|USE |= )Bugzilla/, $text) {
push(@errors, [$lineno, $text]);
diff --git a/template/en/default/admin/params/mta.html.tmpl b/template/en/default/admin/params/mta.html.tmpl
index 4e9691701..357193c3d 100644
--- a/template/en/default/admin/params/mta.html.tmpl
+++ b/template/en/default/admin/params/mta.html.tmpl
@@ -54,25 +54,6 @@
smtpserver => "The SMTP server address (if using SMTP for mail delivery).",
- newchangedmail => "The email that gets sent to people when a $terms.bug changes. Within " _
- "this text, %to% gets replaced with the e-mail address of the " _
- "person receiving the mail. %bugid% gets replaced by the $terms.bug " _
- "number. %diffs% gets replaced with what has changed. " _
- "%neworchanged% is 'New:' if this mail is reporting a new $terms.bug or " _
- "empty if changes were made to an existing one. %summary% gets " _
- "replaced by the summary of this ${terms.bug}. %reasonsheader% is " _
- "replaced by an abbreviated list of reasons why the user is " _
- "getting the email, suitable for use in an email header (such " _
- "as X-Bugzilla-Reason). %reasonsbody% is replaced by text that " _
- "explains why the user is getting the email in more user " _
- "friendly text than %reasonsheader%. " _
- "%threadingmarker% will become either a Message-ID line (for " _
- "new-${terms.bug} messages) or a In-Reply-To line (for ${terms.bug}-change " _
- "messages). " _
- "%<i>anythingelse</i>% gets " _
- "replaced by the definition of that parameter (as defined on " _
- "this page).",
-
whinedays => "The number of days that we'll let a $terms.bug sit untouched in a NEW " _
"state before our cronjob will whine at the owner.<br> " _
"Set to 0 to disable whining." }
diff --git a/template/en/default/email/newchangedmail.txt.tmpl b/template/en/default/email/newchangedmail.txt.tmpl
new file mode 100644
index 000000000..2ae08d538
--- /dev/null
+++ b/template/en/default/email/newchangedmail.txt.tmpl
@@ -0,0 +1,47 @@
+[%# 1.0@bugzilla.org %]
+[%# 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 Netscape Communications
+ # Corporation. Portions created by Netscape are
+ # Copyright (C) 1998 Netscape Communications Corporation. All
+ # Rights Reserved.
+ #
+ # Contributor(s): André Batosti <batosti@async.com.br>
+ #%]
+
+[% PROCESS "global/field-descs.none.tmpl" %]
+From: bugzilla-daemon
+To: [% to %]
+Subject: [[% terms.Bug %] [%+ bugid %]] [% neworchanged %][%+ summary %]
+X-Bugzilla-Reason: [% reasonsheader %]
+X-Bugzilla-Watch-Reason: [% reasonswatchheader %]
+X-Bugzilla-Product: [% product %]
+X-Bugzilla-Component: [% comp %]
+X-Bugzilla-Keywords: [% keywords %]
+X-Bugzilla-Severity: [% severity %]
+X-Bugzilla-Who: [% changer %]
+X-Bugzilla-Status: [% status %]
+X-Bugzilla-Priority: [% priority %]
+X-Bugzilla-Assigned-To: [% assignedto %]
+X-Bugzilla-Target-Milestone: [% targetmilestone %]
+X-Bugzilla-Changed-Fields: [% changedfields %]
+[%+ threadingmarker %]
+
+[%+ Param('urlbase') %]show_bug.cgi?id=[% bugid %]
+
+[%+ diffs %]
+
+--
+Configure bugmail: [% Param('urlbase') %]userprefs.cgi?tab=email
+[%+ reasonsbody %]
+