]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 275636: Templatise 'newchangedmail' email (BugMail) - Patch by André Batosti...
authorlpsolit%gmail.com <>
Tue, 15 Aug 2006 02:45:15 +0000 (02:45 +0000)
committerlpsolit%gmail.com <>
Tue, 15 Aug 2006 02:45:15 +0000 (02:45 +0000)
Bugzilla/BugMail.pm
Bugzilla/Config/MTA.pm
t/009bugwords.t
template/en/default/admin/params/mta.html.tmpl
template/en/default/email/newchangedmail.txt.tmpl [new file with mode: 0644]

index 98a8e92bf465740b322caacc6eac5d9cd68a2471..4221a9dc4935e6e7949da7b6b9b6694835c6b9a9 100644 (file)
@@ -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);
 
index 474160a72a8cd7203b04053e5dda106bd37507da..4364db49b262937a866a176ca30ed9a16c02a2ff 100644 (file)
@@ -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',
index 9249ba4ac66f0331d90aecc67d60cecb237f0473..5b1a9d6ba878204f53dc88fca319ff6b76372979 100644 (file)
@@ -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]);
index 4e9691701e6b811b525e8068936987ddeb610974..357193c3d4545e2a05e3d038cabebe33fe272df4 100644 (file)
 
   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 (file)
index 0000000..2ae08d5
--- /dev/null
@@ -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 %]
+