diff .svn/pristine/b3/b3ae8401c116d3c968d234881e8c4c29afe48532.svn-base @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.svn/pristine/b3/b3ae8401c116d3c968d234881e8c4c29afe48532.svn-base	Fri Feb 24 19:09:32 2012 +0000
@@ -0,0 +1,36 @@
+class FilesController < ApplicationController
+  menu_item :files
+
+  before_filter :find_project_by_project_id
+  before_filter :authorize
+
+  helper :sort
+  include SortHelper
+
+  def index
+    sort_init 'filename', 'asc'
+    sort_update 'filename' => "#{Attachment.table_name}.filename",
+                'created_on' => "#{Attachment.table_name}.created_on",
+                'size' => "#{Attachment.table_name}.filesize",
+                'downloads' => "#{Attachment.table_name}.downloads"
+
+    @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
+    @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
+    render :layout => !request.xhr?
+  end
+
+  def new
+    @versions = @project.versions.sort
+  end
+
+  def create
+    container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
+    attachments = Attachment.attach_files(container, params[:attachments])
+    render_attachment_warning_if_needed(container)
+
+    if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
+      Mailer.deliver_attachments_added(attachments[:files])
+    end
+    redirect_to project_files_path(@project)
+  end
+end