diff --git a/README.md b/README.md index 2ea057f..c45b3cb 100755 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ rake helpdesk:localdb:stop * [Orchitech Solutions](https://github.com/orchitech) - Added support for non-anonymous supportclients (sponsored by ISIC Global Office) * [Orchitech Solutions](https://github.com/orchitech) - Added support for customizable email footers (sponsored by ISIC Global Office) * [Orchitech Solutions](https://github.com/orchitech) - Added support for tracking email details (sponsored by ISIC Global Office) +* [Orchitech Solutions](https://github.com/orchitech) - Added support for sending HTML emails (sponsored by ISIC Global Office) ## License diff --git a/app/views/helpdesk_mailer/email_to_supportclient.html.erb b/app/views/helpdesk_mailer/email_to_supportclient.html.erb new file mode 100644 index 0000000..6ef5203 --- /dev/null +++ b/app/views/helpdesk_mailer/email_to_supportclient.html.erb @@ -0,0 +1,9 @@ + + +
+ + + + <%= Redmine::WikiFormatting.to_html(Setting.text_formatting, @body).html_safe %> + + diff --git a/app/views/helpdesk_mailer/email_to_supportclient.text.erb b/app/views/helpdesk_mailer/email_to_supportclient.text.erb new file mode 100644 index 0000000..31bd20e --- /dev/null +++ b/app/views/helpdesk_mailer/email_to_supportclient.text.erb @@ -0,0 +1 @@ +<%= @body %> diff --git a/db/migrate/008_create_custom_field_for_send_html_emails.rb b/db/migrate/008_create_custom_field_for_send_html_emails.rb new file mode 100644 index 0000000..2a93540 --- /dev/null +++ b/db/migrate/008_create_custom_field_for_send_html_emails.rb @@ -0,0 +1,15 @@ +class CreateCustomFieldForSendHtmlEmails < ActiveRecord::Migration + def self.up + c = CustomField.new( + :name => 'helpdesk-send-html-emails', + :editable => true, + :visible => false, # do not show it on the project summary page + :field_format => 'bool') + c.type = 'ProjectCustomField' # cannot be set by mass assignement! + c.save + end + + def self.down + CustomField.find_by_name('helpdesk-send-html-emails').delete + end +end diff --git a/lib/helpdesk_mailer.rb b/lib/helpdesk_mailer.rb index a61d2e5..39cdfad 100644 --- a/lib/helpdesk_mailer.rb +++ b/lib/helpdesk_mailer.rb @@ -32,8 +32,10 @@ def email_to_supportclient(issue, recipient, journal=nil, text='') # available then use this one instead of the regular r = CustomField.find_by_name('helpdesk-first-reply') f = CustomField.find_by_name('helpdesk-email-footer') + h = CustomField.find_by_name('helpdesk-send-html-emails') reply = p.nil? || r.nil? ? '' : p.custom_value_for(r).try(:value) footer = p.nil? || f.nil? ? '' : p.custom_value_for(f).try(:value) + send_html_emails = p.nil? || h.nil? || p.custom_value_for(h).nil? ? false : p.custom_value_for(h).true? # add any attachements if journal.present? && text.present? journal.details.each do |d| @@ -58,12 +60,13 @@ def email_to_supportclient(issue, recipient, journal=nil, text='') # sending out the journal note to the support client # or the first reply message t = text.present? ? "#{text}\n\n#{footer}" : reply + @body = expand_macros(t, issue, journal) mail( :from => sender.present? && sender || Setting.mail_from, :reply_to => sender.present? && sender || Setting.mail_from, :to => recipient, :subject => subject, - :body => expand_macros(t, issue, journal), + :body => send_html_emails ? nil : @body, :date => Time.zone.now ) else