diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Bug.pm | 2 | ||||
-rw-r--r-- | Bugzilla/BugMail.pm | 24 | ||||
-rw-r--r-- | Bugzilla/Flag.pm | 4 | ||||
-rw-r--r-- | Bugzilla/Install.pm | 3 | ||||
-rw-r--r-- | Bugzilla/Search/Quicksearch.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Token.pm | 6 | ||||
-rw-r--r-- | Bugzilla/User.pm | 11 |
7 files changed, 35 insertions, 17 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, |