aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Bug.pm2
-rw-r--r--Bugzilla/BugMail.pm24
-rw-r--r--Bugzilla/Flag.pm4
-rw-r--r--Bugzilla/Install.pm3
-rw-r--r--Bugzilla/Search/Quicksearch.pm2
-rw-r--r--Bugzilla/Token.pm6
-rw-r--r--Bugzilla/User.pm11
-rw-r--r--extensions/Voting/Extension.pm2
-rwxr-xr-xprocess_bug.cgi2
-rwxr-xr-xrelogin.cgi2
-rwxr-xr-xsanitycheck.cgi2
-rw-r--r--template/en/default/global/setting-descs.none.tmpl3
-rwxr-xr-xwhine.pl2
-rwxr-xr-xwhineatnews.pl2
14 files changed, 44 insertions, 23 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 2ab4a6bff..bf4529f6f 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -3300,7 +3300,7 @@ sub comments {
my @comments = @{ $self->{'comments'} };
my $order = $params->{order}
- || Bugzilla->user->settings->{'comment_sort_order'}->{'value'};
+ || Bugzilla->user->setting('comment_sort_order');
if ($order ne 'oldest_to_newest') {
@comments = reverse @comments;
if ($order eq 'newest_to_oldest_desc_first') {
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 03eb1925d..55eeeab25 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -374,35 +374,41 @@ sub sendMail {
sub _generate_bugmail {
my ($user, $vars) = @_;
- my $template = Bugzilla->template_inner($user->settings->{'lang'}->{'value'});
+ my $template = Bugzilla->template_inner($user->setting('lang'));
my ($msg_text, $msg_html, $msg_header);
$template->process("email/bugmail-header.txt.tmpl", $vars, \$msg_header)
|| ThrowTemplateError($template->error());
$template->process("email/bugmail.txt.tmpl", $vars, \$msg_text)
|| ThrowTemplateError($template->error());
- $template->process("email/bugmail.html.tmpl", $vars, \$msg_html)
- || ThrowTemplateError($template->error());
-
+
my @parts = (
Email::MIME->create(
attributes => {
content_type => "text/plain",
},
body => $msg_text,
- ),
- Email::MIME->create(
+ )
+ );
+ if ($user->setting('email_format') eq 'html') {
+ $template->process("email/bugmail.html.tmpl", $vars, \$msg_html)
+ || ThrowTemplateError($template->error());
+ push @parts, Email::MIME->create(
attributes => {
content_type => "text/html",
},
body => $msg_html,
- ),
- );
+ );
+ }
# TT trims the trailing newline, and threadingmarker may be ignored.
my $email = new Email::MIME("$msg_header\n");
+ if (scalar(@parts) == 1) {
+ $email->content_type_set($parts[0]->content_type);
+ } else {
+ $email->content_type_set('multipart/alternative');
+ }
$email->parts_set(\@parts);
- $email->content_type_set('multipart/alternative');
return $email;
}
diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm
index e8d30bd20..a4b5a026a 100644
--- a/Bugzilla/Flag.pm
+++ b/Bugzilla/Flag.pm
@@ -970,7 +970,7 @@ sub notify {
# use the default language for email notifications.
my $default_lang;
if (grep { !$_ } values %recipients) {
- $default_lang = Bugzilla::User->new()->settings->{'lang'}->{'value'};
+ $default_lang = Bugzilla::User->new()->setting('lang');
}
foreach my $to (keys %recipients) {
@@ -987,7 +987,7 @@ sub notify {
'threadingmarker' => build_thread_marker($bug->id, $thread_user_id) };
my $lang = $recipients{$to} ?
- $recipients{$to}->settings->{'lang'}->{'value'} : $default_lang;
+ $recipients{$to}->setting('lang') : $default_lang;
my $template = Bugzilla->template_inner($lang);
my $message;
diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm
index 808a50698..ce8fe6bad 100644
--- a/Bugzilla/Install.pm
+++ b/Bugzilla/Install.pm
@@ -90,6 +90,9 @@ sub SETTINGS {
timezone => { subclass => 'Timezone', default => 'local' },
# 2011-02-07 dkl@mozilla.com -- Bug 580490
quicksearch_fulltext => { options => ['on', 'off'], default => 'on' },
+ # 2011-06-21 glob@mozilla.com -- Bug 589128
+ email_format => { options => ['html', 'text_only'],
+ default => 'html' },
}
};
diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm
index 25850a378..8425a2be2 100644
--- a/Bugzilla/Search/Quicksearch.pm
+++ b/Bugzilla/Search/Quicksearch.pm
@@ -142,7 +142,7 @@ sub quicksearch {
$searchstring =~ s/(^[\s,]+|[\s,]+$)//g;
ThrowUserError('buglist_parameters_required') unless ($searchstring);
- $fulltext = Bugzilla->user->settings->{'quicksearch_fulltext'}->{'value'} eq 'on' ? 1 : 0;
+ $fulltext = Bugzilla->user->setting('quicksearch_fulltext') eq 'on' ? 1 : 0;
if ($searchstring =~ m/^[0-9,\s]*$/) {
_bug_numbers_only($searchstring);
diff --git a/Bugzilla/Token.pm b/Bugzilla/Token.pm
index e15991f37..69751e905 100644
--- a/Bugzilla/Token.pm
+++ b/Bugzilla/Token.pm
@@ -101,7 +101,7 @@ sub IssueEmailChangeToken {
# Mail the user the token along with instructions for using it.
- my $template = Bugzilla->template_inner($user->settings->{'lang'}->{'value'});
+ my $template = Bugzilla->template_inner($user->setting('lang'));
my $vars = {};
$vars->{'oldemailaddress'} = $old_email . $email_suffix;
@@ -144,7 +144,7 @@ sub IssuePasswordToken {
my ($token, $token_ts) = _create_token($user->id, 'password', remote_ip());
# Mail the user the token along with instructions for using it.
- my $template = Bugzilla->template_inner($user->settings->{'lang'}->{'value'});
+ my $template = Bugzilla->template_inner($user->setting('lang'));
my $vars = {};
$vars->{'token'} = $token;
@@ -292,7 +292,7 @@ sub Cancel {
$vars->{'cancelaction'} = $cancelaction;
# Notify the user via email about the cancellation.
- my $template = Bugzilla->template_inner($user->settings->{'lang'}->{'value'});
+ my $template = Bugzilla->template_inner($user->setting('lang'));
my $message;
$template->process("account/cancel-token.txt.tmpl", $vars, \$message)
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index d21314604..188432241 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -593,11 +593,16 @@ sub settings {
return $self->{'settings'};
}
+sub setting {
+ my ($self, $name) = @_;
+ return $self->settings->{$name}->{'value'};
+}
+
sub timezone {
my $self = shift;
if (!defined $self->{timezone}) {
- my $tz = $self->settings->{timezone}->{value};
+ my $tz = $self->setting('timezone');
if ($tz eq 'local') {
# The user wants the local timezone of the server.
$self->{timezone} = Bugzilla->local_timezone;
@@ -2241,6 +2246,10 @@ value - the value of this setting for this user. Will be the same
is_default - a boolean to indicate whether the user has chosen to make
a preference for themself or use the site default.
+=item C<setting(name)>
+
+Returns the value for the specified setting.
+
=item C<timezone>
Returns the timezone used to display dates and times to the user,
diff --git a/extensions/Voting/Extension.pm b/extensions/Voting/Extension.pm
index 8417e0ec3..8a786e659 100644
--- a/extensions/Voting/Extension.pm
+++ b/extensions/Voting/Extension.pm
@@ -806,7 +806,7 @@ sub _remove_votes {
};
my $voter = new Bugzilla::User($userid);
- my $template = Bugzilla->template_inner($voter->settings->{'lang'}->{'value'});
+ my $template = Bugzilla->template_inner($voter->setting('lang'));
my $msg;
$template->process("voting/votes-removed.txt.tmpl", $vars, \$msg);
diff --git a/process_bug.cgi b/process_bug.cgi
index 0d57bfcfe..0348424fa 100755
--- a/process_bug.cgi
+++ b/process_bug.cgi
@@ -189,7 +189,7 @@ $vars->{'title_tag'} = "bug_processed";
my $action;
if (defined $cgi->param('id')) {
- $action = $user->settings->{'post_bug_submit_action'}->{'value'};
+ $action = $user->setting('post_bug_submit_action');
if ($action eq 'next_bug') {
my $bug_list_obj = $user->recent_search_for($first_bug);
diff --git a/relogin.cgi b/relogin.cgi
index f6a410c05..07796f9f6 100755
--- a/relogin.cgi
+++ b/relogin.cgi
@@ -164,7 +164,7 @@ elsif ($action eq 'begin-sudo') {
# Go ahead and send out the message now
my $message;
- my $mail_template = Bugzilla->template_inner($target_user->settings->{'lang'}->{'value'});
+ my $mail_template = Bugzilla->template_inner($target_user->setting('lang'));
$mail_template->process('email/sudo.txt.tmpl', { reason => $reason }, \$message);
MessageToMTA($message);
diff --git a/sanitycheck.cgi b/sanitycheck.cgi
index 6bf113b24..7d530ea4b 100755
--- a/sanitycheck.cgi
+++ b/sanitycheck.cgi
@@ -76,7 +76,7 @@ my $dbh = Bugzilla->dbh;
# take the user prefs into account rather than querying the web browser.
my $template;
if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
- $template = Bugzilla->template_inner($user->settings->{'lang'}->{'value'});
+ $template = Bugzilla->template_inner($user->setting('lang'));
}
else {
$template = Bugzilla->template;
diff --git a/template/en/default/global/setting-descs.none.tmpl b/template/en/default/global/setting-descs.none.tmpl
index 54683b360..a0b11f048 100644
--- a/template/en/default/global/setting-descs.none.tmpl
+++ b/template/en/default/global/setting-descs.none.tmpl
@@ -49,6 +49,9 @@
"timezone" => "Timezone used to display dates and times",
"local" => "Same as the server",
"quicksearch_fulltext" => "Include comments when performing quick searches (slower)",
+ "email_format" => "Preferred email format",
+ "html" => "HTML",
+ "text_only" => "Text Only",
}
%]
diff --git a/whine.pl b/whine.pl
index 872061fb6..7b8809c25 100755
--- a/whine.pl
+++ b/whine.pl
@@ -367,7 +367,7 @@ sub mail {
# Don't send mail to someone whose bugmail notification is disabled.
return if $addressee->email_disabled;
- my $template = Bugzilla->template_inner($addressee->settings->{'lang'}->{'value'});
+ my $template = Bugzilla->template_inner($addressee->setting('lang'));
my $msg = ''; # it's a temporary variable to hold the template output
$args->{'alternatives'} ||= [];
diff --git a/whineatnews.pl b/whineatnews.pl
index 19b0e44fc..3bfe29871 100755
--- a/whineatnews.pl
+++ b/whineatnews.pl
@@ -88,7 +88,7 @@ foreach my $email (sort (keys %bugs)) {
$vars->{'bugs'} = \@bugs;
my $msg;
- my $template = Bugzilla->template_inner($user->settings->{'lang'}->{'value'});
+ my $template = Bugzilla->template_inner($user->setting('lang'));
$template->process("email/whine.txt.tmpl", $vars, \$msg)
or die($template->error());