Import custom fields values from emails (#2413).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2211 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-12-30 14:57:33 +00:00
parent 2355324d73
commit 421539e3be
3 changed files with 62 additions and 3 deletions
+9 -2
View File
@@ -90,6 +90,13 @@ class MailHandler < ActionMailer::Base
end
issue.subject = email.subject.chomp.toutf8
issue.description = plain_text_body
# custom fields
issue.custom_field_values = issue.available_custom_fields.inject({}) do |h, c|
if value = get_keyword(c.name, :override => true)
h[c.id] = value
end
h
end
issue.save!
add_attachments(issue)
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
@@ -155,8 +162,8 @@ class MailHandler < ActionMailer::Base
end
end
def get_keyword(attr)
if @@handler_options[:allow_override].include?(attr.to_s) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i
def get_keyword(attr, options={})
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i
$1.strip
elsif !@@handler_options[:issue][attr].blank?
@@handler_options[:issue][attr]