From 4fcd8a89ac5968f3558e755e824628c464d62de4 Mon Sep 17 00:00:00 2001 From: vfilippov Date: Wed, 14 Oct 2009 15:22:05 +0000 Subject: [PATCH] Bug 55299 git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@464 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- Bugzilla/BugMail.pm | 10 ++++--- .../custis/code/bugmail-pre_template.pl | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 extensions/custis/code/bugmail-pre_template.pl diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index ac85a7335..014d3ddbf 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -36,6 +36,7 @@ use Bugzilla::Error; use Bugzilla::User; use Bugzilla::Constants; use Bugzilla::Util; +use Bugzilla::Hook; use Bugzilla::Bug; use Bugzilla::Classification; use Bugzilla::Product; @@ -690,11 +691,12 @@ sub sendMail Bugzilla::CustisLocalBugzillas::HackIntoUrlbase($user->email); my $msg; + my $tmpl = ''; + my $template = Bugzilla->template_inner($user->settings->{lang}->{value}); - my $tmpl = '-'.$values{product}; - $tmpl = '' unless $template->template_exists("email/newchangedmail$tmpl.txt.tmpl"); - $template->process("email/newchangedmail$tmpl.txt.tmpl", $vars, \$msg) - || ThrowTemplateError($template->error()); + Bugzilla::Hook::process('bugmail-pre_template', { tmpl => \$tmpl, vars => $vars }); + $tmpl = "email/newchangedmail.txt.tmpl" unless $template->template_exists($tmpl); + $template->process($tmpl, $vars, \$msg) || ThrowTemplateError($template->error()); Bugzilla->template_inner(""); MessageToMTA($msg); diff --git a/extensions/custis/code/bugmail-pre_template.pl b/extensions/custis/code/bugmail-pre_template.pl new file mode 100644 index 000000000..22c811157 --- /dev/null +++ b/extensions/custis/code/bugmail-pre_template.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use Bugzilla::Constants; +use Bugzilla::Util; +use POSIX qw(strftime); + +if (0) +{ +my $vars = Bugzilla->hook_args->{vars}; +${Bugzilla->hook_args->{tmpl}} = 'email/newchangedmail-'.$vars->{product}.'.txt.tmpl'; + +my $datadir = bz_locations()->{datadir}; +my $fd; +if (-w "$datadir/maillog" && open $fd, ">>$datadir/maillog") +{ + my $s = [ strftime("%Y-%m-%d %H:%M:%S: ", localtime) . ($vars->{isnew} ? "" : "Re: ") . "Bug #$vars->{id} mail to $vars->{to}" ]; + if ($vars->{new_comments} && @{$vars->{new_comments}}) + { + push @$s, scalar(@{$vars->{new_comments}}) . ' comments (#' . (join ',', map { $_->{count} } @{$vars->{new_comments}}) . ')'; + } + if ($vars->{diffarray} && @{$vars->{diffarray}}) + { + push @$s, scalar(grep { $_->{type} eq 'change' } @{$vars->{diffarray}}) . ' diffs'; + } + $s = join "; ", @$s; + print $fd $s, "\n"; + close $fd; +} +}