diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index bd38b86b..e818d5ee 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -63,9 +63,13 @@ class DmsfFilesController < ApplicationController access.dmsf_file_revision = @revision access.action = DmsfFileRevisionAccess::DownloadAction access.save! + # Allow a preview of the file by an external plugin + result = { processed: false } + call_hook(:dmsf_files_controller_before_view, { file: @revision.disk_file, result: result }) + return if result[:processed] member = Member.find_by(user_id: User.current.id, project_id: @file.project.id) # IE has got a tendency to cache files - expires_in(0.year, 'must-revalidate' => true) + expires_in 0.year, 'must-revalidate' => true send_file @revision.disk_file, filename: filename_for_content_disposition(@revision.formatted_name(member)), type: @revision.detect_content_type, @@ -162,7 +166,7 @@ class DmsfFilesController < ApplicationController end if ok && @file.save @file.set_last_revision revision - Redmine::Hook.call_hook :dmsf_helper_upload_after_commit, { file: @file } + call_hook :dmsf_helper_upload_after_commit, { file: @file } begin recipients = DmsfMailer.deliver_files_updated(@project, [@file]) if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] diff --git a/app/helpers/dmsf_upload_helper.rb b/app/helpers/dmsf_upload_helper.rb index 08b012f4..d87672b1 100644 --- a/app/helpers/dmsf_upload_helper.rb +++ b/app/helpers/dmsf_upload_helper.rb @@ -97,7 +97,7 @@ module DmsfUploadHelper if container && container.is_a?(Issue) && (!new_object) container.dmsf_file_added file end - Redmine::Hook.call_hook :dmsf_helper_upload_after_commit, { file: file } + call_hook :dmsf_helper_upload_after_commit, { file: file } rescue => e Rails.logger.error e.message controller.flash[:error] = e.message if controller