From a4b07a36edb567948739324b515abc5b7c28b241 Mon Sep 17 00:00:00 2001 From: Nicolas Chuche Date: Wed, 15 Oct 2008 23:50:33 +0000 Subject: add plain text option for mail #2029 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1932 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mailer.rb | 15 +++++++++++++++ app/views/settings/_notifications.rhtml | 4 ++++ 2 files changed, 19 insertions(+) (limited to 'app') diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a2d9ddba5..60a5a827d 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -219,6 +219,21 @@ class Mailer < ActionMailer::Base body[:content_for_layout] = render(:file => method_name, :body => body) ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true) end + + # for the case of plain text only + def body(*params) + value = super(*params) + if Setting.plain_text_mail? + templates = Dir.glob("#{template_path}/#{@template}.text.plain.{rhtml,erb}") + unless String === @body or templates.empty? + template = File.basename(templates.first) + @body[:content_for_layout] = render(:file => template, :body => @body) + @body = ActionView::Base.new(template_root, @body, self).render(:file => "mailer/layout.text.plain.rhtml", :use_full_path => true) + return @body + end + end + return value + end # Makes partial rendering work with Rails 1.2 (retro-compatibility) def self.controller_path diff --git a/app/views/settings/_notifications.rhtml b/app/views/settings/_notifications.rhtml index 36701463a..a9a5f4742 100644 --- a/app/views/settings/_notifications.rhtml +++ b/app/views/settings/_notifications.rhtml @@ -8,6 +8,10 @@

<%= check_box_tag 'settings[bcc_recipients]', 1, Setting.bcc_recipients? %> <%= hidden_field_tag 'settings[bcc_recipients]', 0 %>

+ +

+<%= check_box_tag 'settings[plain_text_mail]', 1, Setting.plain_text_mail? %> +<%= hidden_field_tag 'settings[plain_text_mail]', 0 %>

<%=l(:text_select_mail_notifications)%> -- cgit v1.2.3