summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-01-27 15:01:19 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-01-27 15:01:19 +0000
commit2d47a6d71c0973598bf2d59c59bd4050e77f3861 (patch)
treed5e119cf6d5be90d667c90c4fc81cdd76ceb8543 /app/controllers
parent22c2209cf9229e5f799a9612fadcb6119e412064 (diff)
downloadredmine-2d47a6d71c0973598bf2d59c59bd4050e77f3861.tar.gz
redmine-2d47a6d71c0973598bf2d59c59bd4050e77f3861.zip
mail notifications added when:
* a document is added * a file is added to the project * an attachment is added to an issue or a document git-svn-id: http://redmine.rubyforge.org/svn/trunk@196 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/documents_controller.rb10
-rw-r--r--app/controllers/issues_controller.rb11
-rw-r--r--app/controllers/projects_controller.rb9
3 files changed, 21 insertions, 9 deletions
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index 5ff3583d9..fe0f2d348 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -1,5 +1,5 @@
# redMine - project management software
-# Copyright (C) 2006 Jean-Philippe Lang
+# 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
@@ -46,9 +46,13 @@ class DocumentsController < ApplicationController
def add_attachment
# Save the attachments
- params[:attachments].each { |a|
- Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
+ @attachments = []
+ params[:attachments].each { |file|
+ next unless file.size > 0
+ a = Attachment.create(:container => @document, :file => file, :author => logged_in_user)
+ @attachments << a unless a.new_record?
} if params[:attachments] and params[:attachments].is_a? Array
+ Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
redirect_to :action => 'show', :id => @document
end
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index d37333e37..6ac8bc79b 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -1,5 +1,5 @@
# redMine - project management software
-# Copyright (C) 2006 Jean-Philippe Lang
+# 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
@@ -115,10 +115,13 @@ class IssuesController < ApplicationController
def add_attachment
# Save the attachments
- params[:attachments].each { |a|
- @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
- @attachment.save
+ @attachments = []
+ params[:attachments].each { |file|
+ next unless file.size > 0
+ a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
+ @attachments << a unless a.new_record?
} if params[:attachments] and params[:attachments].is_a? Array
+ Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
redirect_to :action => 'show', :id => @issue
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index f536c39a2..e7db204ed 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -184,6 +184,7 @@ class ProjectsController < ApplicationController
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
} if params[:attachments] and params[:attachments].is_a? Array
flash[:notice] = l(:notice_successful_create)
+ Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
redirect_to :action => 'list_documents', :id => @project
end
end
@@ -385,9 +386,13 @@ class ProjectsController < ApplicationController
if request.post?
@version = @project.versions.find_by_id(params[:version_id])
# Save the attachments
- params[:attachments].each { |a|
- Attachment.create(:container => @version, :file => a, :author => logged_in_user) unless a.size == 0
+ @attachments = []
+ params[:attachments].each { |file|
+ next unless file.size > 0
+ a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
+ @attachments << a unless a.new_record?
} if params[:attachments] and params[:attachments].is_a? Array
+ Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
end
@versions = @project.versions