diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 794288a1..c07d4430 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -729,7 +729,7 @@ class DmsfController < ApplicationController end end # Remove system folders you are not allowed to see because you are not allowed to see the issue - @subfolders = DmsfHelper.visible_folders(@subfolders) + @subfolders = DmsfHelper.visible_folders(@subfolders, @project) end @ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].present? ? Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'] : 100 diff --git a/app/controllers/dmsf_state_controller.rb b/app/controllers/dmsf_state_controller.rb index 18cb263c..642f7aae 100644 --- a/app/controllers/dmsf_state_controller.rb +++ b/app/controllers/dmsf_state_controller.rb @@ -39,7 +39,10 @@ class DmsfStateController < ApplicationController end else flash[:warning] = l(:user_is_not_project_member) - end + end + if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] + @project.update_attribute :dmsf_act_as_attachable, params[:act_as_attachable] + end redirect_to settings_project_path(@project, :tab => 'dmsf') end diff --git a/app/helpers/dmsf_helper.rb b/app/helpers/dmsf_helper.rb index 844b3593..32cfecf4 100644 --- a/app/helpers/dmsf_helper.rb +++ b/app/helpers/dmsf_helper.rb @@ -89,8 +89,9 @@ module DmsfHelper 'plupload/js/i18n/en.js' end - def self.visible_folders(folders) - allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] + def self.visible_folders(folders, project) + allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] && + (project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) folders.reject{ |folder| if folder.system unless allowed @@ -112,7 +113,7 @@ module DmsfHelper def self.all_children_sorted(parent, pos, ident) # Folders && files && links - nodes = visible_folders(parent.dmsf_folders.visible.to_a) + parent.dmsf_links.visible + parent.dmsf_files.visible + nodes = visible_folders(parent.dmsf_folders.visible.to_a, parent.is_a?(Project) ? parent : parent.project) + parent.dmsf_links.visible + parent.dmsf_files.visible # Alphabetical and type sort nodes.sort! do |x, y| if ((x.is_a?(DmsfFolder) || (x.is_a?(DmsfLink) && x.is_folder?)) && diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 5499e7d5..f12d4954 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -44,8 +44,8 @@ class DmsfFile < ActiveRecord::Base :class_name => 'DmsfLink', :foreign_key => 'target_id', :dependent => :destroy has_many :dmsf_public_urls, :dependent => :destroy - STATUS_DELETED = 1 - STATUS_ACTIVE = 0 + STATUS_DELETED = 1.freeze + STATUS_ACTIVE = 0.freeze scope :visible, -> { where(:deleted => STATUS_ACTIVE) } scope :deleted, -> { where(:deleted => STATUS_DELETED) } diff --git a/app/views/dmsf_state/_user_pref.html.erb b/app/views/dmsf_state/_user_pref.html.erb index b74af4b0..af329250 100644 --- a/app/views/dmsf_state/_user_pref.html.erb +++ b/app/views/dmsf_state/_user_pref.html.erb @@ -26,7 +26,7 @@ <%= form_tag(dmsf_user_pref_save_path(@project)) do %>
+ <% if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] %> + + <% end %> <%= submit_tag(l(:submit_save), :title => l(:title_save_preferences)) %> <% end %> \ No newline at end of file diff --git a/db/migrate/20170526144701_dmsf_attachable.rb b/db/migrate/20170526144701_dmsf_attachable.rb new file mode 100644 index 00000000..d35d3a42 --- /dev/null +++ b/db/migrate/20170526144701_dmsf_attachable.rb @@ -0,0 +1,31 @@ +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011-17 Karel Pičman' html << "" @@ -47,7 +48,8 @@ module RedmineDmsf # Add list of attached documents issue = context[:issue] if User.current.allowed_to?(:view_dmsf_files, issue.project) && - Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] + Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] && + (issue.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) links = [] for dmsf_file in issue.dmsf_files if dmsf_file.last_revision diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index 77318b21..841efad8 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -48,6 +48,9 @@ module RedmineDmsf before_save :set_default_dmsf_notification validates_length_of :dmsf_description, :maximum => 65535 + + Project.const_set(:ATTACHABLE_DMS_AND_ATTACHMENTS, 1) + Project.const_set(:ATTACHABLE_ATTACHMENTS, 2) end end