summaryrefslogtreecommitdiffstats
path: root/app/controllers/issues_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/issues_controller.rb')
-rw-r--r--app/controllers/issues_controller.rb11
1 files changed, 7 insertions, 4 deletions
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