From: Jean-Philippe Lang Date: Sun, 30 Nov 2008 14:55:45 +0000 (+0000) Subject: Mail handler: check workflow for status set/change. X-Git-Tag: 0.8.0-RC1~28 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2fa8030afc2fe4773328a8f0debbdfea25b74f10;p=redmine.git Mail handler: check workflow for status set/change. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2074 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index f8e60b6b5..855498211 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -31,7 +31,7 @@ class MailHandler < ActionMailer::Base @@handler_options[:allow_override] ||= [] # Project needs to be overridable if not specified @@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project) - # Status needs to be overridable if not specified + # Status overridable by default @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status) super email end @@ -78,11 +78,15 @@ class MailHandler < ActionMailer::Base tracker = (get_keyword(:tracker) && project.trackers.find_by_name(get_keyword(:tracker))) || project.trackers.find(:first) category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category))) priority = (get_keyword(:priority) && Enumeration.find_by_opt_and_name('IPRI', get_keyword(:priority))) - status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) || IssueStatus.default + status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) # check permission raise UnauthorizedAction unless user.allowed_to?(:add_issues, project) - issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :status => status) + issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority) + # check workflow + if status && issue.new_statuses_allowed_to(user).include?(status) + issue.status = status + end issue.subject = email.subject.chomp.toutf8 issue.description = email.plain_text_body.chomp issue.save! @@ -114,7 +118,10 @@ class MailHandler < ActionMailer::Base # add the note journal = issue.init_journal(user, email.plain_text_body.chomp) add_attachments(issue) - issue.status = status unless status.nil? + # check workflow + if status && issue.new_statuses_allowed_to(user).include?(status) + issue.status = status + end issue.save! logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')