Bug 275636: Templatise 'newchangedmail' email (BugMail) - Patch by Andr� Batosti <batosti@async.com.br> r=LpSolit a=myk

This commit is contained in:
lpsolit%gmail.com 2006-08-14 19:45:16 +00:00
Родитель 305520f8de
Коммит f262528654
5 изменённых файлов: 83 добавлений и 81 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -62,35 +62,6 @@ sub get_param_list {
default => 'localhost'
},
{
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',

Просмотреть файл

@ -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]);

Просмотреть файл

@ -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." }

Просмотреть файл

@ -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 %]