summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Flag.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2008-04-03 00:42:25 +0200
committerlpsolit%gmail.com <>2008-04-03 00:42:25 +0200
commit43b7dc314234e476a80d9acbd07292d7286cca5a (patch)
tree87c77bfa7d65b7636447232feb77fe5db1d7d8d4 /Bugzilla/Flag.pm
parent0e4b8f785d87afacbf432f6985a3d906b35bba21 (diff)
downloadbugzilla-43b7dc314234e476a80d9acbd07292d7286cca5a.tar.gz
bugzilla-43b7dc314234e476a80d9acbd07292d7286cca5a.tar.xz
Bug 405946: Some emails are not sent in the language chosen by the addressee - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wurblzap a=LpSolit
Diffstat (limited to 'Bugzilla/Flag.pm')
-rw-r--r--Bugzilla/Flag.pm58
1 files changed, 28 insertions, 30 deletions
diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm
index f8c43b508..a65a8268b 100644
--- a/Bugzilla/Flag.pm
+++ b/Bugzilla/Flag.pm
@@ -1063,56 +1063,54 @@ or deleted.
sub notify {
my ($flag, $bug, $attachment) = @_;
- my $template = Bugzilla->template;
-
# There is nobody to notify.
return unless ($flag->{'addressee'} || $flag->type->cc_list);
- my $attachment_is_private = $attachment ? $attachment->isprivate : undef;
-
# If the target bug is restricted to one or more groups, then we need
# to make sure we don't send email about it to unauthorized users
# on the request type's CC: list, so we have to trawl the list for users
# not in those groups or email addresses that don't have an account.
my @bug_in_groups = grep {$_->{'ison'} || $_->{'mandatory'}} @{$bug->groups};
+ my $attachment_is_private = $attachment ? $attachment->isprivate : undef;
- if (scalar(@bug_in_groups) || $attachment_is_private) {
- my @new_cc_list;
- foreach my $cc (split(/[, ]+/, $flag->type->cc_list)) {
- my $ccuser = new Bugzilla::User({ name => $cc }) || next;
-
- next if (scalar(@bug_in_groups) && !$ccuser->can_see_bug($bug->bug_id));
- next if $attachment_is_private
- && Bugzilla->params->{"insidergroup"}
- && !$ccuser->in_group(Bugzilla->params->{"insidergroup"});
- push(@new_cc_list, $cc);
- }
- $flag->type->{'cc_list'} = join(", ", @new_cc_list);
+ my %recipients;
+ foreach my $cc (split(/[, ]+/, $flag->type->cc_list)) {
+ my $ccuser = new Bugzilla::User({ name => $cc });
+ next if (scalar(@bug_in_groups) && (!$ccuser || !$ccuser->can_see_bug($bug->bug_id)));
+ next if $attachment_is_private && (!$ccuser || !$ccuser->is_insider);
+ # Prevent duplicated entries due to case sensitivity.
+ $cc = $ccuser ? $ccuser->email : $cc;
+ $recipients{$cc} = $ccuser;
}
- # If there is nobody left to notify, return.
- return unless ($flag->{'addressee'} || $flag->type->cc_list);
-
- my @recipients = split(/[, ]+/, $flag->type->cc_list);
# Only notify if the addressee is allowed to receive the email.
if ($flag->{'addressee'} && $flag->{'addressee'}->email_enabled) {
- push @recipients, $flag->{'addressee'}->email;
+ $recipients{$flag->{'addressee'}->email} = $flag->{'addressee'};
}
- # Process and send notification for each recipient
- foreach my $to (@recipients)
- {
- next unless $to;
+ # Process and send notification for each recipient.
+ # If there are users in the CC list who don't have an account,
+ # use the default language for email notifications.
+ my $default_lang;
+ if (grep { !$_ } values %recipients) {
+ my $default_user = new Bugzilla::User();
+ $default_lang = $default_user->settings->{'lang'}->{'value'};
+ }
+
+ foreach my $to (keys %recipients) {
my $vars = { 'flag' => $flag,
'to' => $to,
'bug' => $bug,
'attachment' => $attachment};
+
+ my $lang = $recipients{$to} ?
+ $recipients{$to}->settings->{'lang'}->{'value'} : $default_lang;
+
+ my $template = Bugzilla->template_inner($lang);
my $message;
- my $rv = $template->process("request/email.txt.tmpl", $vars, \$message);
- if (!$rv) {
- Bugzilla->cgi->header();
- ThrowTemplateError($template->error());
- }
+ $template->process("request/email.txt.tmpl", $vars, \$message)
+ || ThrowTemplateError($template->error());
+ Bugzilla->template_inner("");
MessageToMTA($message);
}
}