diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/documents_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/issues_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/news_controller.rb | 1 | ||||
-rw-r--r-- | app/models/changeset.rb | 1 | ||||
-rw-r--r-- | app/models/document_observer.rb | 22 | ||||
-rw-r--r-- | app/models/issue_observer.rb | 22 | ||||
-rw-r--r-- | app/models/journal_observer.rb | 22 | ||||
-rw-r--r-- | app/models/mail_handler.rb | 7 | ||||
-rw-r--r-- | app/models/news_observer.rb | 22 |
9 files changed, 91 insertions, 14 deletions
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 965614149..f5825e7c3 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -48,7 +48,6 @@ class DocumentsController < ApplicationController if request.post? and @document.save attach_files(@document, params[:attachments]) flash[:notice] = l(:notice_successful_create) - Mailer.deliver_document_added(@document) if Setting.notified_events.include?('document_added') redirect_to :action => 'index', :project_id => @project end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 929b928ac..a41dc5040 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -146,7 +146,6 @@ class IssuesController < ApplicationController if @issue.save attach_files(@issue, params[:attachments]) flash[:notice] = l(:notice_successful_create) - Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added') call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) redirect_to(params[:continue] ? { :action => 'new', :tracker_id => @issue.tracker } : { :action => 'show', :id => @issue }) @@ -193,7 +192,6 @@ class IssuesController < ApplicationController if !journal.new_record? # Only send notification if something was actually changed flash[:notice] = l(:notice_successful_update) - Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated') end call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal}) redirect_to(params[:back_to] || {:action => 'show', :id => @issue}) @@ -247,10 +245,7 @@ class IssuesController < ApplicationController issue.custom_field_values = custom_field_values if custom_field_values && !custom_field_values.empty? call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) # Don't save any change to the issue if the user is not authorized to apply the requested status - if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save - # Send notification for each issue (if changed) - Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') - else + unless (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save # Keep unsaved issue ids to display them in flash error unsaved_issue_ids << issue.id end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index b5f7ca1b2..9fc9f5b6a 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -45,7 +45,6 @@ class NewsController < ApplicationController @news.attributes = params[:news] if @news.save flash[:notice] = l(:notice_successful_create) - Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added') redirect_to :controller => 'news', :action => 'index', :project_id => @project end end diff --git a/app/models/changeset.rb b/app/models/changeset.rb index e29de363b..41b4befc6 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -113,7 +113,6 @@ class Changeset < ActiveRecord::Base issue.status = fix_status issue.done_ratio = done_ratio if done_ratio issue.save - Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated') end end referenced_issues += target_issues diff --git a/app/models/document_observer.rb b/app/models/document_observer.rb new file mode 100644 index 000000000..3125c97b3 --- /dev/null +++ b/app/models/document_observer.rb @@ -0,0 +1,22 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class DocumentObserver < ActiveRecord::Observer + def after_create(document) + Mailer.deliver_document_added(document) if Setting.notified_events.include?('document_added') + end +end diff --git a/app/models/issue_observer.rb b/app/models/issue_observer.rb new file mode 100644 index 000000000..bdb5c1d4a --- /dev/null +++ b/app/models/issue_observer.rb @@ -0,0 +1,22 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class IssueObserver < ActiveRecord::Observer + def after_create(issue) + Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added') + end +end diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb new file mode 100644 index 000000000..5604e064e --- /dev/null +++ b/app/models/journal_observer.rb @@ -0,0 +1,22 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class JournalObserver < ActiveRecord::Observer + def after_create(journal) + Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated') + end +end diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 9b6410d57..023e1d63c 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -110,13 +110,11 @@ class MailHandler < ActionMailer::Base end h end + # add To and Cc as watchers before saving so the watchers can reply to Redmine + add_watchers(issue) issue.save! add_attachments(issue) logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info - # add To and Cc as watchers - add_watchers(issue) - # send notification after adding watchers so that they can reply to Redmine - Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added') issue end @@ -148,7 +146,6 @@ class MailHandler < ActionMailer::Base 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') journal end diff --git a/app/models/news_observer.rb b/app/models/news_observer.rb new file mode 100644 index 000000000..e10aec55e --- /dev/null +++ b/app/models/news_observer.rb @@ -0,0 +1,22 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class NewsObserver < ActiveRecord::Observer + def after_create(news) + Mailer.deliver_news_added(news) if Setting.notified_events.include?('news_added') + end +end |