Index: mozilla/webtools/bugzilla/Bugzilla/BugMail.pm =================================================================== RCS file: /cvsroot/mozilla/webtools/bugzilla/Bugzilla/BugMail.pm,v retrieving revision 1.106 diff -pu -r1.106 mozilla/webtools/bugzilla/Bugzilla/BugMail.pm --- mozilla/webtools/bugzilla/Bugzilla/BugMail.pm +++ mozilla/webtools/bugzilla/Bugzilla/BugMail.pm @@ -58,6 +58,16 @@ use constant REL_NAMES => { REL_GLOBAL_WATCHER, "GlobalWatcher" }; +sub FormatTripleHeader { + my ($a, $b, $c) = (@_); + $^A = ""; + my $temp = formline << 'END', $a, $b, $c; +^<<<<<<<<<<<<<<<<<<|^<<<<<<<<<<<<<<<<<<<<<<<<<<<|^<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ +END + ; # This semicolon appeases my emacs editor macros. :-) + return $^A . ('-' x 76) . "\n"; +} + sub FormatTriple { my ($a, $b, $c) = (@_); $^A = ""; @@ -227,11 +237,22 @@ sub Send { my $diffpart = {}; if ($who ne $lastwho) { $lastwho = $who; - $fullwho = $whoname ? "$whoname <$who" . Bugzilla->params->{'emailsuffix'} . ">" : - "$who" . Bugzilla->params->{'emailsuffix'}; - $diffheader = "\n$fullwho changed:\n\n"; - $diffheader .= FormatTriple("What ", "Removed", "Added"); - $diffheader .= ('-' x 76) . "\n"; + my $who_with_suffix = $who . Bugzilla->params->{'emailsuffix'}; + $fullwho = $whoname ? "$whoname <$who_with_suffix>" : + $who_with_suffix; + my $vars = { + bugid => $id, + who => Bugzilla::User->new({name => $who}), + format_triple => \&FormatTriple, + format_triple_header => \&FormatTripleHeader + }; + my $relatedmsg; + my $template = Bugzilla->template_inner( + $user->settings->{'lang'}->{'value'}); + $template->process("email/bugchanges.txt.tmpl", + $vars, \$relatedmsg) + || ThrowTemplateError($template->error()); + Bugzilla->template_inner(""); } $what =~ s/^(Attachment )?/Attachment #$attachid / if $attachid; if( $fieldname eq 'estimated_time' || @@ -296,13 +317,21 @@ sub Send { $deptext .= $thisdiff; } $lastbug = $depbug; - my $urlbase = Bugzilla->params->{"urlbase"}; - $thisdiff = - "\nBug $id depends on bug $depbug, which changed state.\n\n" . - "Bug $depbug Summary: $summary\n" . - "${urlbase}show_bug.cgi?id=$depbug\n\n"; - $thisdiff .= FormatTriple("What ", "Old Value", "New Value"); - $thisdiff .= ('-' x 76) . "\n"; + my $vars = { + bugid => $id, + depbug => $depbug, + summary => $summary, + format_triple => \&FormatTriple, + format_triple_header => \&FormatTripleHeader + }; + my $relatedmsg; + my $template = Bugzilla->template_inner( + $user->settings->{'lang'}->{'value'}); + $template->process("email/bugchanges.txt.tmpl", + $vars, \$relatedmsg) + || ThrowTemplateError($template->error()); + Bugzilla->template_inner(""); + $thisdiff .= $relatedmsg; $interestingchange = 0; } $thisdiff .= FormatTriple($fielddescription{$what}, $old, $new); Index: mozilla/webtools/bugzilla/Bugzilla/User.pm =================================================================== RCS file: /cvsroot/mozilla/webtools/bugzilla/Bugzilla/User.pm,v retrieving revision 1.153 diff -pu -r1.153 mozilla/webtools/bugzilla/Bugzilla/User.pm --- mozilla/webtools/bugzilla/Bugzilla/User.pm +++ mozilla/webtools/bugzilla/Bugzilla/User.pm @@ -252,8 +252,8 @@ sub authorizer { return $self->{authorizer}; } -# Generate a string to identify the user by name + login if the user -# has a name or by login only if she doesn't. +# Generate a string to identify the user by name + email if the user +# has a name or by email only if she doesn't. sub identity { my $self = shift; @@ -261,7 +261,7 @@ sub identity { if (!defined $self->{identity}) { $self->{identity} = - $self->name ? $self->name . " <" . $self->login. ">" : $self->login; + $self->name ? $self->name . " <" . $self->email. ">" : $self->login; } return $self->{identity}; @@ -1799,8 +1799,8 @@ Returns the login name for this user. =item C -Returns the user's email address. Currently this is the same value as the -login. +Returns the user's email address. Currently this is tied to the login, +although it can include a suffix. =item C Index: mozilla/webtools/bugzilla/Bugzilla/Util.pm =================================================================== RCS file: /cvsroot/mozilla/webtools/bugzilla/Bugzilla/Util.pm,v retrieving revision 1.57 diff -pu -r1.57 mozilla/webtools/bugzilla/Bugzilla/Util.pm --- mozilla/webtools/bugzilla/Bugzilla/Util.pm +++ mozilla/webtools/bugzilla/Bugzilla/Util.pm @@ -44,7 +44,7 @@ use base qw(Exporter); file_mod_time is_7bit_clean bz_crypt generate_random_password validate_email_syntax clean_text - get_text); + get_text get_term); use Bugzilla::Constants; @@ -502,6 +502,15 @@ sub get_text { return $message; } +sub get_term { + my ($name) = @_; + my %info; + my $template = Bugzilla->template_inner->process( + \"PROCESS global/variables.none.tmpl; save.terms = terms;", + { save => \%info } + ); + return $info{$name}; +} sub get_netaddr { my $ipaddr = shift; @@ -825,6 +834,33 @@ A string. =back +=item C + +=over + +=item B + +This is a method for getting a globally replaced term within Bugzilla code. +Use this when you don't want to use TT and just need access to [% Terms.x %]. + +It uses the F template to return a string. + +=item B + +=over + +=item C<$term> - The term to be replaced. + +=back + +=item B + +A string. + +=back + +=back + =head2 Formatting Time =over 4 Index: mozilla/webtools/bugzilla/template/en/default/email/bugchanges.txt.tmpl --- /dev/null +++ mozilla/webtools/bugzilla/template/en/default/email/bugchanges.txt.tmpl @@ -0,0 +1,37 @@ +[%# 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): + #%] + +[% PROCESS "global/variables.none.tmpl" %] + +[% IF depbug %] +[% Terms.Bug %] [% id %] [% depends on %] [% Terms.bug %] [% depbug %], which changed state. + +[%+ Terms.Bug %] [% depbug %] Summary: [% summary %] +[%+ urlbase %]show_bug.cgi?id=[% depbug %] + +[%+ format_triple_header($terms.What, $terms.OldValue, $terms.NewValue) %] +[% ELSE %] +[% who.identity %] changed: + +[%+ format_triple_header($terms.What, $terms.Removed, $terms.Added) %] +[% ENDIF %] + +#[% a = '-'; a.repeat(76); %] Index: mozilla/webtools/bugzilla/template/en/default/global/field-descs.none.tmpl =================================================================== RCS file: /cvsroot/mozilla/webtools/bugzilla/template/en/default/global/field-descs.none.tmpl,v retrieving revision 1.20 diff -pu -r1.20 mozilla/webtools/bugzilla/template/en/default/global/field-descs.none.tmpl --- mozilla/webtools/bugzilla/template/en/default/global/field-descs.none.tmpl +++ mozilla/webtools/bugzilla/template/en/default/global/field-descs.none.tmpl @@ -67,7 +67,8 @@ "target_milestone" => "Target Milestone", "version" => "Version", "votes" => "Votes", - "work_time" => "Hours Worked"} %] + "work_time" => "Hours Worked"}, + %] [%# Also include any custom fields or fields which don't have a Description here, by copying their Description from the Index: mozilla/webtools/bugzilla/template/en/default/global/variables.none.tmpl =================================================================== RCS file: /cvsroot/mozilla/webtools/bugzilla/template/en/default/global/variables.none.tmpl,v retrieving revision 1.4 diff -pu -r1.4 mozilla/webtools/bugzilla/template/en/default/global/variables.none.tmpl --- mozilla/webtools/bugzilla/template/en/default/global/variables.none.tmpl +++ mozilla/webtools/bugzilla/template/en/default/global/variables.none.tmpl @@ -52,6 +52,13 @@ "zeroSearchResults" => "Zarro Boogs found", "bit" => "bit", "bits" => "bits", - "Bugzilla" => "Bugzilla" + "Bugzilla" => "Bugzilla", + "Added" => "Added", + "Who" => "Who", + "What" => "What", + "When" => "When", + "Removed" => "Removed", + "NewValue" => "New Value", + "OldValue" => "Old Value" } %]