diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index 2904e5d8..1d36a368 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -29,6 +29,19 @@ class DmsfFilesController < ApplicationController helper :all helper :dmsf_workflows + def view + @revision = @file.last_revision + + check_project(@revision.file) + access = DmsfFileRevisionAccess.new(:user_id => User.current.id, :dmsf_file_revision_id => @revision.id, + :action => DmsfFileRevisionAccess::DownloadAction) + access.save! + send_file(@revision.disk_file, + :filename => filename_for_content_disposition(@revision.name), + :type => @revision.detect_content_type, + :disposition => 'inline') + end + def show # The download is put here to provide more clear and usable links if params.has_key?(:download) diff --git a/app/views/dmsf/_file.html.erb b/app/views/dmsf/_file.html.erb index fc698207..d15f6b3d 100644 --- a/app/views/dmsf/_file.html.erb +++ b/app/views/dmsf/_file.html.erb @@ -25,12 +25,13 @@ <%= check_box_tag(name, id, false, :title => l(:title_check_for_zip_download_or_email)) %> - <% file_download_url = url_for({:only_path => false, :controller => :dmsf_files, :action => 'show', :id => file, :download => ''}) %> + <% file_view_url = url_for({:only_path => false, :controller => :dmsf_files, :action => 'view', :id => file}) %> <%= link_to(h(title), - file_download_url, + file_view_url, + :target => "_blank", :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}", :title => l(:title_title_version_version_download, :title => h(file.title), :version => file.version), - 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_download_url}") %> + 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") %>
<%= h(link ? link.path : file.display_name) %>
<%= number_to_human_size(file.last_revision.size) %> diff --git a/config/routes.rb b/config/routes.rb index 161360a5..359669f1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,6 +73,7 @@ RedmineApp::Application.routes.draw do get '/dmsf/files/:id/revision/delete', :controller => 'dmsf_files', :action => 'delete_revision', :as => 'delete_revision' get '/dmsf/files/:id/download', :controller => 'dmsf_files', :action => 'show', :download => '' # Otherwise will not route nil download param get '/dmsf/files/:id/download/:download', :controller => 'dmsf_files', :action => 'show', :as => 'download_revision' + get '/dmsf/files/:id/view', :controller => 'dmsf_files', :action => 'view' get '/dmsf/files/:id', :controller => 'dmsf_files', :action => 'show', :as => 'dmsf_file' delete '/dmsf/files/:id', :controller => 'dmsf_files', :action => 'delete' get '/dmsf/files/:id/restore', :controller => 'dmsf_files', :action => 'restore', :as => 'restore_dmsf_file' diff --git a/init.rb b/init.rb index ca2a16c7..84150a11 100644 --- a/init.rb +++ b/init.rb @@ -59,7 +59,7 @@ Redmine::Plugin.register :redmine_dmsf do {:dmsf_state => [:user_pref_save]} permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email, :download_email_entries, :tag_changed], - :dmsf_files => [:show], + :dmsf_files => [:show, :view], :dmsf_files_copy => [:new, :create, :move], :dmsf_workflows => [:log]}, :read => true