From 3a892ecfd4b03d9918a81bedb915dae3a41823f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Fri, 3 Jan 2020 08:12:41 +0100 Subject: [PATCH] Redmine 4.1 compatibility --- Gemfile | 2 +- after_init.rb | 1 + .../dmsf_context_menus_controller.rb | 1 + app/controllers/dmsf_controller.rb | 5 +- app/controllers/dmsf_files_controller.rb | 13 +- app/controllers/dmsf_files_copy_controller.rb | 3 + .../dmsf_folder_permissions_controller.rb | 1 + .../dmsf_folders_copy_controller.rb | 3 + app/controllers/dmsf_links_controller.rb | 3 +- .../dmsf_public_urls_controller.rb | 3 +- app/controllers/dmsf_state_controller.rb | 1 + app/controllers/dmsf_upload_controller.rb | 1 + app/controllers/dmsf_workflows_controller.rb | 1 + app/helpers/dmsf_files_helper.rb | 1 + app/helpers/dmsf_folder_permissions_helper.rb | 1 + app/helpers/dmsf_helper.rb | 3 +- app/helpers/dmsf_links_helper.rb | 3 +- app/helpers/dmsf_upload_helper.rb | 5 +- app/helpers/dmsf_workflows_helper.rb | 11 +- app/models/dmsf_file.rb | 15 +- app/models/dmsf_file_revision.rb | 23 +- app/models/dmsf_file_revision_access.rb | 1 + app/models/dmsf_file_revision_custom_field.rb | 1 + app/models/dmsf_folder.rb | 13 +- app/models/dmsf_folder_permission.rb | 1 + app/models/dmsf_link.rb | 1 + app/models/dmsf_lock.rb | 1 + app/models/dmsf_mailer.rb | 1 + app/models/dmsf_public_url.rb | 1 + app/models/dmsf_upload.rb | 1 + app/models/dmsf_workflow.rb | 1 + app/models/dmsf_workflow_step.rb | 1 + app/models/dmsf_workflow_step_action.rb | 1 + app/models/dmsf_workflow_step_assignment.rb | 1 + .../easy_dms/epm_dmsf_locked_documents.rb | 1 + .../easy_dms/epm_dmsf_open_approvals.rb | 1 + app/validators/dmsf_file_name_validator.rb | 1 + app/validators/dmsf_url_validator.rb | 1 + .../dmsf_workflow_name_validator.rb | 1 + assets/stylesheets/redmine_dmsf.css | 4 +- config/routes.rb | 1 + db/migrate/07_dmsf_1_4_4.rb | 2 +- .../20170422104901_migrate_documents.rb | 4 +- extra/api/api_client.rb | 1 + extra/xapian_indexer.rb | 7 +- init.rb | 1 + lib/dav4rack/controller.rb | 2 - lib/redmine_dmsf.rb | 1 + lib/redmine_dmsf/dmsf_zip.rb | 1 + lib/redmine_dmsf/errors/dmsf_access_error.rb | 1 + lib/redmine_dmsf/errors/dmsf_content_error.rb | 1 + .../errors/dmsf_email_max_file_error.rb | 1 + .../errors/dmsf_file_not_found_error.rb | 1 + lib/redmine_dmsf/errors/dmsf_lock_error.rb | 1 + .../errors/dmsf_zip_max_file_error.rb | 1 + .../controllers/issues_controller_hooks.rb | 1 + .../controllers/search_controller_hooks.rb | 1 + .../hooks/helpers/issues_helper_hooks.rb | 1 + .../hooks/helpers/search_helper_hooks.rb | 3 +- .../hooks/views/issue_view_hooks.rb | 8 +- lib/redmine_dmsf/lockable.rb | 1 + lib/redmine_dmsf/macros.rb | 3 +- lib/redmine_dmsf/patches/attachable_patch.rb | 1 + .../patches/easy_crm_case_patch.rb | 1 + .../easy_crm_cases_controller_patch.rb | 1 + lib/redmine_dmsf/patches/issue_patch.rb | 1 + lib/redmine_dmsf/patches/project_patch.rb | 1 + .../patches/projects_helper_patch.rb | 3 + lib/redmine_dmsf/patches/role_patch.rb | 1 + lib/redmine_dmsf/patches/user_patch.rb | 1 + .../patches/user_preference_patch.rb | 1 + lib/redmine_dmsf/webdav/base_resource.rb | 13 +- lib/redmine_dmsf/webdav/custom_middleware.rb | 1 + lib/redmine_dmsf/webdav/dmsf_resource.rb | 3 +- lib/redmine_dmsf/webdav/index_resource.rb | 1 + lib/redmine_dmsf/webdav/project_resource.rb | 1 + lib/redmine_dmsf/webdav/resource_proxy.rb | 1 + lib/tasks/dmsf_alert_approvals.rake | 1 + lib/tasks/dmsf_convert_documents.rake | 5 +- lib/tasks/dmsf_create_digests.rake | 1 + lib/tasks/dmsf_maintenance.rake | 3 +- .../dmsf_context_menus_controller_test.rb | 1 + test/functional/dmsf_controller_test.rb | 3 +- test/functional/dmsf_files_controller_test.rb | 3 +- .../dmsf_files_copy_controller_test.rb | 3 +- ...dmsf_folder_permissions_controller_test.rb | 1 + .../dmsf_folders_copy_controller_test.rb | 3 +- test/functional/dmsf_links_controller_test.rb | 1 + .../dmsf_public_urls_controller_test.rb | 1 + test/functional/dmsf_state_controller_test.rb | 1 + .../dmsf_workflow_controller_test.rb | 1 + test/functional/issues_controller_test.rb | 3 +- test/functional/my_controller_test.rb | 1 + .../rest_api/dmsf_file_api_test.rb | 6 +- .../rest_api/dmsf_folder_api_test.rb | 6 +- .../rest_api/dmsf_link_api_test.rb | 1 + .../dmsf_webdav_custom_middleware_test.rb | 1 + .../webdav/dmsf_webdav_delete_test.rb | 3 +- .../webdav/dmsf_webdav_get_test.rb | 197 +++++++++--------- .../webdav/dmsf_webdav_head_test.rb | 3 +- .../webdav/dmsf_webdav_lock_test.rb | 16 +- .../webdav/dmsf_webdav_mkcol_test.rb | 3 +- .../webdav/dmsf_webdav_move_test.rb | 118 ++++++----- .../webdav/dmsf_webdav_options_test.rb | 1 + .../webdav/dmsf_webdav_post_test.rb | 1 + .../webdav/dmsf_webdav_propfind_test.rb | 1 + .../webdav/dmsf_webdav_put_test.rb | 132 +++++++----- test/integration_test.rb | 4 +- test/test_case.rb | 1 + test/test_helper.rb | 1 + test/unit/attachable_patch_test.rb | 1 + test/unit/dmsf_file_revision_test.rb | 7 +- test/unit/dmsf_file_test.rb | 5 +- test/unit/dmsf_folder_permission_test.rb | 1 + test/unit/dmsf_folder_test.rb | 1 + test/unit/dmsf_link_test.rb | 1 + test/unit/dmsf_lock_test.rb | 1 + test/unit/dmsf_mailer_test.rb | 1 + test/unit/dmsf_public_url_test.rb | 1 + test/unit/dmsf_workflow_step_action_test.rb | 3 +- .../dmsf_workflow_step_assignment_test.rb | 1 + test/unit/dmsf_workflow_step_test.rb | 1 + test/unit/dmsf_workflow_test.rb | 1 + test/unit/issue_patch_test.rb | 1 + test/unit/project_patch_test.rb | 1 + test/unit/user_patch_test.rb | 1 + test/unit_test.rb | 1 + 127 files changed, 468 insertions(+), 297 deletions(-) diff --git a/Gemfile b/Gemfile index e6511368..26d9a216 100644 --- a/Gemfile +++ b/Gemfile @@ -30,7 +30,7 @@ gem 'dalli' # Redmine extensions unless %w(easyproject easy_gantt).any? { |plugin| Dir.exist?(File.expand_path("../../#{plugin}", __FILE__)) } - gem 'redmine_extensions', '~> 0.2.5' + gem 'redmine_extensions', '~> 0.3.9' end # Dav4Rack diff --git a/after_init.rb b/after_init.rb index 791f8e23..e80bdba4 100644 --- a/after_init.rb +++ b/after_init.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/controllers/dmsf_context_menus_controller.rb b/app/controllers/dmsf_context_menus_controller.rb index 20547503..bbcb6aff 100644 --- a/app/controllers/dmsf_context_menus_controller.rb +++ b/app/controllers/dmsf_context_menus_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 1f7fe1b1..8230ec3c 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -94,7 +95,7 @@ class DmsfController < ApplicationController :filename => 'Documents.zip', :type => 'application/zip', :disposition => 'attachment') - rescue Exception => e + rescue => e flash[:errors] = e.message end @@ -525,7 +526,7 @@ class DmsfController < ApplicationController flash[:warning] = l(:warning_email_notifications, :to => to) end end - rescue Exception => e + rescue => e Rails.logger.error "Could not send email notifications: #{e.message}" end end diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index 7126583f..8e8ee3e5 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -72,7 +73,7 @@ class DmsfFilesController < ApplicationController rescue DmsfAccessError => e Rails.logger.error e.message render_403 - rescue Exception => e + rescue => e Rails.logger.error e.message render_404 end @@ -165,7 +166,7 @@ class DmsfFilesController < ApplicationController begin @file.unlock! flash[:notice] = "#{l(:notice_file_unlocked)}, " - rescue Exception => e + rescue => e Rails.logger.error "Cannot unlock the file: #{e.message}" end end @@ -181,7 +182,7 @@ class DmsfFilesController < ApplicationController flash[:warning] = l(:warning_email_notifications, :to => to) end end - rescue Exception => e + rescue => e Rails.logger.error "Could not send email notifications: #{e.message}" end else @@ -211,7 +212,7 @@ class DmsfFilesController < ApplicationController flash[:warning] = l(:warning_email_notifications, :to => to) end end - rescue Exception => e + rescue => e Rails.logger.error "Could not send email notifications: #{e.message}" end end @@ -266,7 +267,7 @@ class DmsfFilesController < ApplicationController begin @file.lock! flash[:notice] = l(:notice_file_locked) - rescue Exception => e + rescue => e flash[:errors] = e.message end end @@ -281,7 +282,7 @@ class DmsfFilesController < ApplicationController begin @file.unlock! flash[:notice] = l(:notice_file_unlocked) - rescue Exception => e + rescue => e flash[:errors] = e.message end else diff --git a/app/controllers/dmsf_files_copy_controller.rb b/app/controllers/dmsf_files_copy_controller.rb index f432718b..c4a80c97 100644 --- a/app/controllers/dmsf_files_copy_controller.rb +++ b/app/controllers/dmsf_files_copy_controller.rb @@ -1,3 +1,6 @@ +# encoding: utf-8 +# frozen_string_literal: true +# # Redmine plugin for Document Management System "Features" # # Copyright © 2011 Vít Jonáš diff --git a/app/controllers/dmsf_folder_permissions_controller.rb b/app/controllers/dmsf_folder_permissions_controller.rb index ad5b7e41..37f07303 100644 --- a/app/controllers/dmsf_folder_permissions_controller.rb +++ b/app/controllers/dmsf_folder_permissions_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/controllers/dmsf_folders_copy_controller.rb b/app/controllers/dmsf_folders_copy_controller.rb index c3c8ba9f..e31da850 100644 --- a/app/controllers/dmsf_folders_copy_controller.rb +++ b/app/controllers/dmsf_folders_copy_controller.rb @@ -1,3 +1,6 @@ +# encoding: utf-8 +# frozen_string_literal: true +# # Redmine plugin for Document Management System "Features" # # Copyright © 2011 Vít Jonáš diff --git a/app/controllers/dmsf_links_controller.rb b/app/controllers/dmsf_links_controller.rb index 256491d3..99b2ce21 100644 --- a/app/controllers/dmsf_links_controller.rb +++ b/app/controllers/dmsf_links_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -175,7 +176,7 @@ class DmsfLinksController < ApplicationController end end end - rescue Exception => e + rescue => e errors[:base] << e.message return false end diff --git a/app/controllers/dmsf_public_urls_controller.rb b/app/controllers/dmsf_public_urls_controller.rb index e26e1db8..b862df28 100644 --- a/app/controllers/dmsf_public_urls_controller.rb +++ b/app/controllers/dmsf_public_urls_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -35,7 +36,7 @@ class DmsfPublicUrlsController < ApplicationController :filename => filename_for_content_disposition(revision.name), :type => revision.detect_content_type, :disposition => dmsf_public_url.dmsf_file.disposition) - rescue Exception => e + rescue => e Rails.logger.error e.message render_404 end diff --git a/app/controllers/dmsf_state_controller.rb b/app/controllers/dmsf_state_controller.rb index 60c7f5b6..235c01d0 100644 --- a/app/controllers/dmsf_state_controller.rb +++ b/app/controllers/dmsf_state_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index b6403e0e..d14b1e34 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb index 0be8485a..a9176096 100644 --- a/app/controllers/dmsf_workflows_controller.rb +++ b/app/controllers/dmsf_workflows_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/helpers/dmsf_files_helper.rb b/app/helpers/dmsf_files_helper.rb index 3890996b..9406b21f 100644 --- a/app/helpers/dmsf_files_helper.rb +++ b/app/helpers/dmsf_files_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/helpers/dmsf_folder_permissions_helper.rb b/app/helpers/dmsf_folder_permissions_helper.rb index 710ae176..7e81b14b 100644 --- a/app/helpers/dmsf_folder_permissions_helper.rb +++ b/app/helpers/dmsf_folder_permissions_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/helpers/dmsf_helper.rb b/app/helpers/dmsf_helper.rb index a65c1a62..9f90086e 100644 --- a/app/helpers/dmsf_helper.rb +++ b/app/helpers/dmsf_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -64,7 +65,7 @@ module DmsfHelper extension = extension[1, extension.length-1] path = File.join(Redmine::Plugin.public_directory, ['redmine_dmsf', 'images', 'filetypes', "#{extension}.png"]) if File.exist?(path) - cls = "filetype-#{extension}"; + cls = +"filetype-#{extension}"; else cls = Redmine::MimeType.css_class_of(filename) end diff --git a/app/helpers/dmsf_links_helper.rb b/app/helpers/dmsf_links_helper.rb index 2942dc17..b068eb09 100644 --- a/app/helpers/dmsf_links_helper.rb +++ b/app/helpers/dmsf_links_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -21,7 +22,7 @@ module DmsfLinksHelper def folder_tree_options_for_select(folder_tree, options = {}) - s = '' + s = +'' folder_tree.each do |name, id| tag_options = {:value => id} if id == options[:selected] diff --git a/app/helpers/dmsf_upload_helper.rb b/app/helpers/dmsf_upload_helper.rb index 2ee242e6..14ba93cf 100644 --- a/app/helpers/dmsf_upload_helper.rb +++ b/app/helpers/dmsf_upload_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -109,7 +110,7 @@ module DmsfUploadHelper if file.container.is_a?(Issue) file.container.dmsf_file_added(file) end - rescue Exception => e + rescue => e Rails.logger.error e.message controller.flash[:errors] = e.message if controller failed_uploads.push(file) @@ -150,7 +151,7 @@ module DmsfUploadHelper controller.flash[:warning] = l(:warning_email_notifications, :to => to) if controller end end - rescue Exception => e + rescue => e Rails.logger.error "Could not send email notifications: #{e.message}" end end diff --git a/app/helpers/dmsf_workflows_helper.rb b/app/helpers/dmsf_workflows_helper.rb index 859052bf..d7b60491 100644 --- a/app/helpers/dmsf_workflows_helper.rb +++ b/app/helpers/dmsf_workflows_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -92,19 +93,19 @@ module DmsfWorkflowsHelper end def principals_radio_button_tags(name, principals) - s = '' + s = +'' principals.each do |principal| - s << "\n" + s << "\n" end s.html_safe end def change_status_link(workflow) - url = { :controller => 'dmsf_workflows', :action => 'update', :id => workflow.id } + url = { controller: 'dmsf_workflows', action: 'update', id: workflow.id } if workflow.locked? - link_to l(:button_unlock), url.merge(:dmsf_workflow => {:status => DmsfWorkflow::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' + link_to l(:button_unlock), url.merge(dmsf_workflow: { status: DmsfWorkflow::STATUS_ACTIVE }), method: :put, class: 'icon icon-unlock' else - link_to l(:button_lock), url.merge(:dmsf_workflow => {:status => DmsfWorkflow::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock' + link_to l(:button_lock), url.merge(dmsf_workflow: { status: DmsfWorkflow::STATUS_LOCKED }), method: :put, class: 'icon icon-lock' end end diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index f979542b..31f0644b 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -63,7 +64,7 @@ class DmsfFile < ActiveRecord::Base Redmine::Search.cache_store.delete("DmsfFile-#{o.id}") else # Set desc to an empty string if o.description is nil - desc = o.description.nil? ? '' : o.description + desc = o.description.nil? ? +'' : +o.description desc += ' / ' if o.description.present? && o.last_revision.comment.present? desc += o.last_revision.comment if o.last_revision.comment.present? end @@ -150,7 +151,7 @@ class DmsfFile < ActiveRecord::Base self.deleted_by_user = User.current save end - rescue Exception => e + rescue => e Rails.logger.error e.message errors[:base] << e.message return false @@ -239,10 +240,10 @@ class DmsfFile < ActiveRecord::Base self.dmsf_folder = folder new_revision = last_revision.clone new_revision.dmsf_file = self - new_revision.comment = l(:comment_moved_from, :source => source) + new_revision.comment = l(:comment_moved_from, source: source) new_revision.custom_values = [] last_revision.custom_values.each do |cv| - new_revision.custom_values << CustomValue.new({:custom_field => cv.custom_field, :value => cv.value}) + new_revision.custom_values << CustomValue.new({ custom_field: cv.custom_field, value: cv.value }) end set_last_revision(new_revision) save && new_revision.save @@ -339,7 +340,7 @@ class DmsfFile < ActiveRecord::Base databasepath = File.join( Setting.plugin_redmine_dmsf['dmsf_index_database'].strip, lang) database = Xapian::Database.new(databasepath) - rescue Exception => e + rescue => e Rails.logger.error "REDMINE_XAPIAN ERROR: Xapian database is not properly set, initiated or it's corrupted." Rails.logger.error e.message end @@ -448,7 +449,7 @@ class DmsfFile < ActiveRecord::Base end def preview(limit) - result = 'No preview available' + result = +'No preview available' if text? begin f = File.new(last_revision.disk_file) @@ -462,7 +463,7 @@ class DmsfFile < ActiveRecord::Base result << line end end - rescue Exception => e + rescue => e result = e.message end end diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index a040a4be..20cc8f43 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -203,7 +204,7 @@ class DmsfFileRevision < ActiveRecord::Base content_type = mime_type content_type = Redmine::MimeType.of(disk_filename) if content_type.blank? content_type = 'application/octet-stream' if content_type.blank? - content_type.to_s + content_type end def clone @@ -307,13 +308,13 @@ class DmsfFileRevision < ActiveRecord::Base else filename = name end - format2 = format.dup - format2.sub!('%t', title) - format2.sub!('%f', filename) - format2.sub!('%d', updated_at.strftime('%Y%m%d%H%M%S')) - format2.sub!('%v', version) - format2.sub!('%i', dmsf_file.id.to_s) - format2.sub!('%r', id.to_s) + format2 = format + format2 = format2.sub('%t', title) + format2 = format2.sub('%f', filename) + format2 = format2.sub('%d', updated_at.strftime('%Y%m%d%H%M%S')) + format2 = format2.sub('%v', version) + format2 = format2.sub('%i', dmsf_file.id.to_s) + format2 = format2.sub('%r', id.to_s) format2 += ext if ext format2 end @@ -321,7 +322,7 @@ class DmsfFileRevision < ActiveRecord::Base def self.create_digest(path) begin Digest::SHA256.file(path).hexdigest - rescue Exception => e + rescue => e Rails.logger.error e.message 0 end @@ -340,7 +341,7 @@ class DmsfFileRevision < ActiveRecord::Base if description.present? text = description else - text = '' + text = +'' end if comment.present? text += ' / ' if text.present? @@ -350,7 +351,7 @@ class DmsfFileRevision < ActiveRecord::Base end def workflow_tooltip - tooltip = '' + tooltip = +'' if dmsf_workflow case workflow when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL, DmsfWorkflow::STATE_ASSIGNED diff --git a/app/models/dmsf_file_revision_access.rb b/app/models/dmsf_file_revision_access.rb index c3c9240f..4e0383ca 100644 --- a/app/models/dmsf_file_revision_access.rb +++ b/app/models/dmsf_file_revision_access.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_file_revision_custom_field.rb b/app/models/dmsf_file_revision_custom_field.rb index 7572ecea..2c0d83a3 100644 --- a/app/models/dmsf_file_revision_custom_field.rb +++ b/app/models/dmsf_file_revision_custom_field.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 8250abe6..5b920d9b 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -43,7 +44,7 @@ class DmsfFolder < ActiveRecord::Base :class_name => 'DmsfLock', :foreign_key => 'entity_id', :dependent => :destroy has_many :dmsf_folder_permissions, :dependent => :destroy - INVALID_CHARACTERS = '\[\]\/\\\?":<>#%\*'.freeze + INVALID_CHARACTERS = '\[\]\/\\\?":<>#%\*' STATUS_DELETED = 1 STATUS_ACTIVE = 0 AVAILABLE_COLUMNS = %w(id title extension size modified version workflow author).freeze @@ -52,16 +53,14 @@ class DmsfFolder < ActiveRecord::Base def self.visible_condition(system=true) Project.allowed_to_condition(User.current, :view_dmsf_folders) do |role, user| if role.member? - permissions = "#{DmsfFolderPermission.table_name}" - folders = "#{DmsfFolder.table_name}" group_ids = user.group_ids.join(',') group_ids = -1 if group_ids.blank? allowed = (system && role.allowed_to?(:display_system_folders)) ? 1 : 0 %{ - ((#{permissions}.object_id IS NULL) OR - (#{permissions}.object_id = #{role.id} AND #{permissions}.object_type = 'Role') OR - ((#{permissions}.object_id = #{user.id} OR #{permissions}.object_id IN (#{group_ids})) AND #{permissions}.object_type = 'User')) AND - (#{folders}.system = #{DmsfFolder.connection.quoted_false} OR 1 = #{allowed}) + ((#{DmsfFolderPermission.table_name}.object_id IS NULL) OR + (#{DmsfFolderPermission.table_name}.object_id = #{role.id} AND #{DmsfFolderPermission.table_name}.object_type = 'Role') OR + ((#{DmsfFolderPermission.table_name}.object_id = #{user.id} OR #{DmsfFolderPermission.table_name}.object_id IN (#{group_ids})) AND #{DmsfFolderPermission.table_name}.object_type = 'User')) AND + (#{DmsfFolder.table_name}.system = #{DmsfFolder.connection.quoted_false} OR 1 = #{allowed}) } end end diff --git a/app/models/dmsf_folder_permission.rb b/app/models/dmsf_folder_permission.rb index be29d43b..fed817ac 100644 --- a/app/models/dmsf_folder_permission.rb +++ b/app/models/dmsf_folder_permission.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_link.rb b/app/models/dmsf_link.rb index 80b24b51..8b3abd8f 100644 --- a/app/models/dmsf_link.rb +++ b/app/models/dmsf_link.rb @@ -1,4 +1,5 @@ # encode: utf-8 + # frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_lock.rb b/app/models/dmsf_lock.rb index 386bb4d5..5f205f75 100644 --- a/app/models/dmsf_lock.rb +++ b/app/models/dmsf_lock.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 4da11fee..6e27fd6a 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_public_url.rb b/app/models/dmsf_public_url.rb index 6a1b39c4..c7b6ed24 100644 --- a/app/models/dmsf_public_url.rb +++ b/app/models/dmsf_public_url.rb @@ -1,4 +1,5 @@ # encode: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_upload.rb b/app/models/dmsf_upload.rb index 5fcdbdec..bb78f0f7 100644 --- a/app/models/dmsf_upload.rb +++ b/app/models/dmsf_upload.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_workflow.rb b/app/models/dmsf_workflow.rb index d1fc0215..fa457c1a 100644 --- a/app/models/dmsf_workflow.rb +++ b/app/models/dmsf_workflow.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_workflow_step.rb b/app/models/dmsf_workflow_step.rb index 621f204a..f783e1d5 100644 --- a/app/models/dmsf_workflow_step.rb +++ b/app/models/dmsf_workflow_step.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_workflow_step_action.rb b/app/models/dmsf_workflow_step_action.rb index 3d5787fd..423c6f2b 100644 --- a/app/models/dmsf_workflow_step_action.rb +++ b/app/models/dmsf_workflow_step_action.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/dmsf_workflow_step_assignment.rb b/app/models/dmsf_workflow_step_assignment.rb index e8971a47..a289a548 100644 --- a/app/models/dmsf_workflow_step_assignment.rb +++ b/app/models/dmsf_workflow_step_assignment.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/easy_page_modules/easy_dms/epm_dmsf_locked_documents.rb b/app/models/easy_page_modules/easy_dms/epm_dmsf_locked_documents.rb index 180ed7c4..eae6c859 100644 --- a/app/models/easy_page_modules/easy_dms/epm_dmsf_locked_documents.rb +++ b/app/models/easy_page_modules/easy_dms/epm_dmsf_locked_documents.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/models/easy_page_modules/easy_dms/epm_dmsf_open_approvals.rb b/app/models/easy_page_modules/easy_dms/epm_dmsf_open_approvals.rb index 425618a6..e7fad635 100644 --- a/app/models/easy_page_modules/easy_dms/epm_dmsf_open_approvals.rb +++ b/app/models/easy_page_modules/easy_dms/epm_dmsf_open_approvals.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/validators/dmsf_file_name_validator.rb b/app/validators/dmsf_file_name_validator.rb index 697d0f09..08d080cb 100644 --- a/app/validators/dmsf_file_name_validator.rb +++ b/app/validators/dmsf_file_name_validator.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/validators/dmsf_url_validator.rb b/app/validators/dmsf_url_validator.rb index c29f1f9c..1b70f20c 100644 --- a/app/validators/dmsf_url_validator.rb +++ b/app/validators/dmsf_url_validator.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/app/validators/dmsf_workflow_name_validator.rb b/app/validators/dmsf_workflow_name_validator.rb index f563a173..e7e6c33e 100644 --- a/app/validators/dmsf_workflow_name_validator.rb +++ b/app/validators/dmsf_workflow_name_validator.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/assets/stylesheets/redmine_dmsf.css b/assets/stylesheets/redmine_dmsf.css index 9250296d..7d253a0a 100644 --- a/assets/stylesheets/redmine_dmsf.css +++ b/assets/stylesheets/redmine_dmsf.css @@ -71,8 +71,8 @@ } .list .dmsf_buttons { - min-width: 96px; - width: 96px; + min-width: 98px; + width: 98px; text-align: left; } diff --git a/config/routes.rb b/config/routes.rb index 385c4569..35ec03ac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/db/migrate/07_dmsf_1_4_4.rb b/db/migrate/07_dmsf_1_4_4.rb index da486d2f..19c33af2 100644 --- a/db/migrate/07_dmsf_1_4_4.rb +++ b/db/migrate/07_dmsf_1_4_4.rb @@ -94,7 +94,7 @@ class Dmsf144 < ActiveRecord::Migration[4.2] end end say 'Action was successful' - rescue Exception => e + rescue => e say 'Action was not successful' puts e.message puts e.backtrace.inspect # See issue #86 diff --git a/db/migrate/20170422104901_migrate_documents.rb b/db/migrate/20170422104901_migrate_documents.rb index e9ec1eaa..285cac59 100644 --- a/db/migrate/20170422104901_migrate_documents.rb +++ b/db/migrate/20170422104901_migrate_documents.rb @@ -35,7 +35,7 @@ class MigrateDocuments < ActiveRecord::Migration[4.2] FileUtils.mv origin, target, :verbose => true folder = storage_base_path(dmsf_file_revision) Dir.rmdir(folder) if (folder && (Dir.entries(folder).size == 2)) - rescue Exception => e + rescue => e msg = "DmsfFileRevisions ID #{dmsf_file_revision.id}: #{e.message}" say msg Rails.logger.error msg @@ -92,7 +92,7 @@ class MigrateDocuments < ActiveRecord::Migration[4.2] FileUtils.mv origin, target, :verbose => true folder = dmsf_file_revision.storage_base_path Dir.rmdir(folder) if (folder && (Dir.entries(folder).size == 2)) - rescue Exception => e + rescue => e msg = "DmsfFileRevisions ID #{dmsf_file_revision.id}: #{e.message}" say msg Rails.logger.error msg diff --git a/extra/api/api_client.rb b/extra/api/api_client.rb index 1cf503d1..aa921931 100644 --- a/extra/api/api_client.rb +++ b/extra/api/api_client.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/extra/xapian_indexer.rb b/extra/xapian_indexer.rb index bd1aa0dc..ddcea7c1 100644 --- a/extra/xapian_indexer.rb +++ b/extra/xapian_indexer.rb @@ -1,6 +1,7 @@ #!/usr/bin/ruby -W0 # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -60,7 +61,7 @@ $databasepath = nil $env = 'production' $retryfailed = nil -VERSION = '0.2'.freeze +VERSION = '0.2' optparse = OptionParser.new do |opts| opts.banner = 'Usage: xapian_indexer.rb [OPTIONS...]' @@ -132,12 +133,12 @@ $stem_langs.each do | lang | log "#{databasepath} does not exist, creating ..." begin FileUtils.mkdir_p databasepath - rescue Exception => e + rescue => e log e.message, true exit 1 end end - cmd = "#{$omindex} -s #{lang} --db #{databasepath} #{filespath} --url / --depth-limit=0" + cmd = +"#{$omindex} -s #{lang} --db #{databasepath} #{filespath} --url / --depth-limit=0" cmd << ' -v' if $verbose > 0 cmd << ' --retry-failed' if $retryfailed log cmd diff --git a/init.rb b/init.rb index bd3d3043..9d5ff847 100644 --- a/init.rb +++ b/init.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/dav4rack/controller.rb b/lib/dav4rack/controller.rb index da77a260..c8a68a5d 100644 --- a/lib/dav4rack/controller.rb +++ b/lib/dav4rack/controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require 'uri' require 'dav4rack/destination_header' require 'dav4rack/request' diff --git a/lib/redmine_dmsf.rb b/lib/redmine_dmsf.rb index 8913c4f4..424c12e3 100644 --- a/lib/redmine_dmsf.rb +++ b/lib/redmine_dmsf.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/dmsf_zip.rb b/lib/redmine_dmsf/dmsf_zip.rb index 03fa3b7a..b7ea07cf 100644 --- a/lib/redmine_dmsf/dmsf_zip.rb +++ b/lib/redmine_dmsf/dmsf_zip.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/errors/dmsf_access_error.rb b/lib/redmine_dmsf/errors/dmsf_access_error.rb index 108ba6a0..b6d11426 100644 --- a/lib/redmine_dmsf/errors/dmsf_access_error.rb +++ b/lib/redmine_dmsf/errors/dmsf_access_error.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/errors/dmsf_content_error.rb b/lib/redmine_dmsf/errors/dmsf_content_error.rb index 8cd695fd..092904d0 100644 --- a/lib/redmine_dmsf/errors/dmsf_content_error.rb +++ b/lib/redmine_dmsf/errors/dmsf_content_error.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/errors/dmsf_email_max_file_error.rb b/lib/redmine_dmsf/errors/dmsf_email_max_file_error.rb index d4f4113c..8d7f6281 100644 --- a/lib/redmine_dmsf/errors/dmsf_email_max_file_error.rb +++ b/lib/redmine_dmsf/errors/dmsf_email_max_file_error.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/errors/dmsf_file_not_found_error.rb b/lib/redmine_dmsf/errors/dmsf_file_not_found_error.rb index 4801b3bf..271cfaba 100644 --- a/lib/redmine_dmsf/errors/dmsf_file_not_found_error.rb +++ b/lib/redmine_dmsf/errors/dmsf_file_not_found_error.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/errors/dmsf_lock_error.rb b/lib/redmine_dmsf/errors/dmsf_lock_error.rb index 613a6b3d..1910d70a 100644 --- a/lib/redmine_dmsf/errors/dmsf_lock_error.rb +++ b/lib/redmine_dmsf/errors/dmsf_lock_error.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/errors/dmsf_zip_max_file_error.rb b/lib/redmine_dmsf/errors/dmsf_zip_max_file_error.rb index 51d7e6b5..9af0a204 100644 --- a/lib/redmine_dmsf/errors/dmsf_zip_max_file_error.rb +++ b/lib/redmine_dmsf/errors/dmsf_zip_max_file_error.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb b/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb index f4492875..11680c62 100644 --- a/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb +++ b/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/hooks/controllers/search_controller_hooks.rb b/lib/redmine_dmsf/hooks/controllers/search_controller_hooks.rb index b3457383..610d5f57 100644 --- a/lib/redmine_dmsf/hooks/controllers/search_controller_hooks.rb +++ b/lib/redmine_dmsf/hooks/controllers/search_controller_hooks.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/hooks/helpers/issues_helper_hooks.rb b/lib/redmine_dmsf/hooks/helpers/issues_helper_hooks.rb index d18f5455..df08a50d 100644 --- a/lib/redmine_dmsf/hooks/helpers/issues_helper_hooks.rb +++ b/lib/redmine_dmsf/hooks/helpers/issues_helper_hooks.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # diff --git a/lib/redmine_dmsf/hooks/helpers/search_helper_hooks.rb b/lib/redmine_dmsf/hooks/helpers/search_helper_hooks.rb index 4aa9001a..3419d2ff 100644 --- a/lib/redmine_dmsf/hooks/helpers/search_helper_hooks.rb +++ b/lib/redmine_dmsf/hooks/helpers/search_helper_hooks.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Document Management System "Features" # @@ -30,7 +31,7 @@ module RedmineDmsf str = context[:controller].send(:render_to_string, :partial => 'search/container', :locals => { :object => context[:entity] }) if str - html = '

' + html = +'

' if context[:entity].dmsf_folder_id html << context[:entity].class.human_attribute_name(:folder) else diff --git a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb index 9e68c304..f28a6ad6 100644 --- a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb +++ b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb @@ -35,7 +35,7 @@ module RedmineDmsf # Radio buttons if allowed_to_attach_documents(context[:container]) html << '

' - classes = 'inline' + classes = +'inline' html << "