An option to remove the original Documents module
This commit is contained in:
parent
5262fdcf10
commit
c502b834c4
@ -4,6 +4,8 @@ Changelog for Redmine DMSF
|
||||
3.0.13 ????-??-??
|
||||
------------------
|
||||
|
||||
An option to disable the original module Documents in the plugin's settings
|
||||
|
||||
3.0.12 2023-03-15
|
||||
------------------
|
||||
|
||||
|
||||
@ -144,10 +144,6 @@ Rails.application.configure do
|
||||
Redmine::Activity.register :dmsf_file_revision_accesses, default: false
|
||||
Redmine::Activity.register :dmsf_file_revisions
|
||||
|
||||
# Uncomment to remove the original Documents from searching and project's modules (replaced with DMSF)
|
||||
# Redmine::Search.available_search_types.delete('documents')
|
||||
# Redmine::AccessControl.available_project_modules.delete(:documents)
|
||||
|
||||
if Redmine::Plugin.installed?('easy_extensions')
|
||||
require "#{File.dirname(__FILE__)}/lib/redmine_dmsf/webdav/custom_middleware"
|
||||
config.middleware.insert_before ActionDispatch::Cookies, RedmineDmsf::Webdav::CustomMiddleware
|
||||
|
||||
@ -176,6 +176,14 @@
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag :label, l(:label_remove_original_documents_module) %>
|
||||
<%= check_box_tag 'settings[remove_original_documents_module]', false, @settings['remove_original_documents_module'] %>
|
||||
<em class="<%= klass %>">
|
||||
<%= l(:label_default) %>: <%= l(:general_text_No) %>
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<em class="<%= title_klass %>">
|
||||
<%= l(:label_dmsf_columns) %>
|
||||
|
||||
@ -468,6 +468,8 @@ cs:
|
||||
field_default_dmsf_query: Výchozí dotaz DMS
|
||||
field_receive_download_notification: Dostávat notifikace o stažení
|
||||
|
||||
label_remove_original_documents_module: Odstranit původní modul Dokumenty
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -464,6 +464,8 @@ de:
|
||||
field_default_dmsf_query: Standardabfrage DMS
|
||||
field_receive_download_notification: Bekomen Benachrichtigen über Herunterladen
|
||||
|
||||
label_remove_original_documents_module: Entfernen originelles Modul Dokumente
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: Von mir gesperrte Dokumente
|
||||
|
||||
@ -468,6 +468,8 @@ en:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -468,6 +468,8 @@ es:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -447,6 +447,8 @@ fa:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: اسناد قفل شدهی من
|
||||
|
||||
@ -468,6 +468,8 @@ fr:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -467,6 +467,8 @@ hu:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -468,6 +468,8 @@ it: # Italian strings thx 2 Matteo Arceci!
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -469,6 +469,8 @@ ja:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: 自分がロック中の文書
|
||||
|
||||
@ -468,6 +468,8 @@ ko:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: 내 잠긴 파일
|
||||
|
||||
@ -468,6 +468,8 @@ nl:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -468,6 +468,8 @@ pl:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -468,6 +468,8 @@ pt-BR:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -468,6 +468,8 @@ sl:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -467,6 +467,8 @@ zh-TW:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -468,6 +468,8 @@ zh:
|
||||
field_default_dmsf_query: Default DMS query
|
||||
field_receive_download_notification: Receive download notifications
|
||||
|
||||
label_remove_original_documents_module: Remove the original Documents module
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
3
init.rb
3
init.rb
@ -63,7 +63,8 @@ Redmine::Plugin.register :redmine_dmsf do
|
||||
'office_bin' => 'libreoffice',
|
||||
'dmsf_global_menu_disabled' => nil,
|
||||
'dmsf_default_query' => nil,
|
||||
'empty_minor_version_by_default' => nil
|
||||
'empty_minor_version_by_default' => nil,
|
||||
'remove_original_documents_module' => nil
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/issue_patch"
|
||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/role_patch"
|
||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/queries_controller_patch"
|
||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/pdf_patch"
|
||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/access_control_patch"
|
||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/patches/search_patch"
|
||||
|
||||
# A workaround for obsolete 'alias_method' usage in RedmineUp's plugins
|
||||
if RedmineDmsf::Plugin.an_obsolete_plugin_present?
|
||||
|
||||
56
lib/redmine_dmsf/patches/access_control_patch.rb
Normal file
56
lib/redmine_dmsf/patches/access_control_patch.rb
Normal file
@ -0,0 +1,56 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineDmsf
|
||||
module Patches
|
||||
# AccessControll patch
|
||||
module AccessControlPatch
|
||||
##################################################################################################################
|
||||
# Overriden methods
|
||||
def self.prepended(base)
|
||||
class << base
|
||||
prepend ClassMethods
|
||||
end
|
||||
end
|
||||
|
||||
# Class methods
|
||||
module ClassMethods
|
||||
def available_project_modules
|
||||
# Removes the original Documents from project's modules (replaced with DMSF)
|
||||
if Setting.plugin_redmine_dmsf['remove_original_documents_module']
|
||||
super.reject { |m| m == :documents }
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?('easy_extensions')
|
||||
RedmineExtensions::PatchManager.register_patch_to_be_first 'Redmine::Acts::Attachable::InstanceMethods',
|
||||
'RedmineDmsf::Patches::AccessControlPatch',
|
||||
prepend: true,
|
||||
first: true
|
||||
else
|
||||
Redmine::AccessControl.prepend RedmineDmsf::Patches::AccessControlPatch
|
||||
end
|
||||
56
lib/redmine_dmsf/patches/search_patch.rb
Normal file
56
lib/redmine_dmsf/patches/search_patch.rb
Normal file
@ -0,0 +1,56 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineDmsf
|
||||
module Patches
|
||||
# Search patch
|
||||
module SearchPatch
|
||||
##################################################################################################################
|
||||
# Overridden methods
|
||||
def self.prepended(base)
|
||||
class << base
|
||||
prepend ClassMethods
|
||||
end
|
||||
end
|
||||
|
||||
# Class methods
|
||||
module ClassMethods
|
||||
def available_search_types
|
||||
# Removes the original Documents from searching (replaced with DMSF)
|
||||
if Setting.plugin_redmine_dmsf['remove_original_documents_module']
|
||||
super.reject { |t| t == 'documents' }
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?('easy_extensions')
|
||||
RedmineExtensions::PatchManager.register_patch_to_be_first 'Redmine::Acts::Attachable::InstanceMethods',
|
||||
'RedmineDmsf::Patches::SearchPatch',
|
||||
prepend: true,
|
||||
first: true
|
||||
else
|
||||
Redmine::Search.prepend RedmineDmsf::Patches::SearchPatch
|
||||
end
|
||||
31
test/unit/lib/acccess_control_patch_test.rb
Normal file
31
test/unit/lib/acccess_control_patch_test.rb
Normal file
@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
# AccessControl patch tests
|
||||
class AccessControlPatchTest < RedmineDmsf::Test::UnitTest
|
||||
def test_available_project_modules
|
||||
Setting.plugin_redmine_dmsf['remove_original_documents_module'] = nil
|
||||
assert Redmine::AccessControl.available_project_modules.include?(:documents)
|
||||
Setting.plugin_redmine_dmsf['remove_original_documents_module'] = '1'
|
||||
assert_not Redmine::AccessControl.available_project_modules.include?(:documents)
|
||||
end
|
||||
end
|
||||
@ -18,7 +18,7 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
# Attachable tests
|
||||
class AttachablePatchTest < RedmineDmsf::Test::UnitTest
|
||||
31
test/unit/lib/search_patch_test.rb
Normal file
31
test/unit/lib/search_patch_test.rb
Normal file
@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
# Search patch tests
|
||||
class SearchPatchTest < RedmineDmsf::Test::UnitTest
|
||||
def test_available_search_types
|
||||
Setting.plugin_redmine_dmsf['remove_original_documents_module'] = nil
|
||||
assert Redmine::Search.available_search_types.include?('documents')
|
||||
Setting.plugin_redmine_dmsf['remove_original_documents_module'] = '1'
|
||||
assert_not Redmine::Search.available_search_types.include?('documents')
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user