diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2008-08-20 06:21:06 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2008-08-20 06:21:06 +0000 |
commit | 2f3f2d8b12483b72f78f7f4704d8641451b16832 (patch) | |
tree | 98742d143b5e0ce8a89278e7f638af387fc3d200 /app/models/mail_handler.rb | |
parent | 6db8fa8ef762bafb09ce1c2419a8392e119caece (diff) | |
download | redmine-2f3f2d8b12483b72f78f7f4704d8641451b16832.tar.gz redmine-2f3f2d8b12483b72f78f7f4704d8641451b16832.zip |
Added the "Status:" keyword to the MailHandler for setting and changing an Issue status via email.
#1669
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1751 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/mail_handler.rb')
-rw-r--r-- | app/models/mail_handler.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 109db2989..2f1eba3e9 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -31,6 +31,8 @@ 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 + @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status) super email end @@ -76,10 +78,11 @@ 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 # check permission raise UnauthorizedAction unless user.allowed_to?(:add_issues, project) - issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority) + issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :status => status) issue.subject = email.subject.chomp issue.description = email.plain_text_body.chomp issue.save! @@ -100,13 +103,18 @@ class MailHandler < ActionMailer::Base # Adds a note to an existing issue def receive_issue_update(issue_id) + status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) + issue = Issue.find_by_id(issue_id) return unless issue # check permission raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || user.allowed_to?(:edit_issues, issue.project) + raise UnauthorizedAction unless status.nil? || user.allowed_to?(:edit_issues, issue.project) + # add the note journal = issue.init_journal(user, email.plain_text_body.chomp) add_attachments(issue) + issue.status = status unless status.nil? 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') |