Plugin settings 'Display notified recipients' does not apply! #1565
This commit is contained in:
parent
acde546449
commit
48da1908d7
@ -55,7 +55,7 @@ def dmsf_init
|
|||||||
if: proc {
|
if: proc {
|
||||||
User.current.allowed_to?(:view_dmsf_folders, nil, global: true) &&
|
User.current.allowed_to?(:view_dmsf_folders, nil, global: true) &&
|
||||||
ActiveRecord::Base.connection.data_source_exists?('settings') &&
|
ActiveRecord::Base.connection.data_source_exists?('settings') &&
|
||||||
Setting.plugin_redmine_dmsf['dmsf_global_menu_disabled'].blank?
|
!RedmineDmsf.dmsf_global_menu_disabled?
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class DmsfContextMenusController < ApplicationController
|
|||||||
@unlockable = @allowed && @dmsf_file.unlockable? && (!@dmsf_file.locked_for_user? ||
|
@unlockable = @allowed && @dmsf_file.unlockable? && (!@dmsf_file.locked_for_user? ||
|
||||||
User.current.allowed_to?(:force_file_unlock, @project))
|
User.current.allowed_to?(:force_file_unlock, @project))
|
||||||
@email_allowed = User.current.allowed_to?(:email_documents, @project)
|
@email_allowed = User.current.allowed_to?(:email_documents, @project)
|
||||||
@preview = RedmineDmsf::Preview.office_available? && Setting.plugin_redmine_dmsf['office_bin'].blank?
|
@preview = RedmineDmsf.office_bin.present? && RedmineDmsf::Preview.office_available?
|
||||||
elsif @dmsf_folder
|
elsif @dmsf_folder
|
||||||
@locked = @dmsf_folder.locked?
|
@locked = @dmsf_folder.locked?
|
||||||
@project = @dmsf_folder.project
|
@project = @dmsf_folder.project
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class DmsfController < ApplicationController
|
|||||||
@notifications = Setting.notified_events.include?('dmsf_legacy_notifications')
|
@notifications = Setting.notified_events.include?('dmsf_legacy_notifications')
|
||||||
@query.dmsf_folder_id = @folder ? @folder.id : nil
|
@query.dmsf_folder_id = @folder ? @folder.id : nil
|
||||||
@query.deleted = false
|
@query.deleted = false
|
||||||
@query.sub_projects |= Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'].present?
|
@query.sub_projects |= RedmineDmsf.dmsf_projects_as_subfolders?
|
||||||
if @folder&.deleted? || (params[:folder_title].present? && !@folder)
|
if @folder&.deleted? || (params[:folder_title].present? && !@folder)
|
||||||
render_404
|
render_404
|
||||||
return
|
return
|
||||||
@ -501,7 +501,7 @@ class DmsfController < ApplicationController
|
|||||||
zip_entries(zip, selected_folders, selected_files)
|
zip_entries(zip, selected_folders, selected_files)
|
||||||
zipped_content = zip.finish
|
zipped_content = zip.finish
|
||||||
|
|
||||||
max_filesize = Setting.plugin_redmine_dmsf['dmsf_max_email_filesize'].to_f
|
max_filesize = RedmineDmsf.dmsf_max_email_filesize
|
||||||
if max_filesize.positive? && File.size(zipped_content) > max_filesize * 1_048_576
|
if max_filesize.positive? && File.size(zipped_content) > max_filesize * 1_048_576
|
||||||
raise RedmineDmsf::Errors::DmsfEmailMaxFileSizeError
|
raise RedmineDmsf::Errors::DmsfEmailMaxFileSizeError
|
||||||
end
|
end
|
||||||
@ -527,9 +527,8 @@ class DmsfController < ApplicationController
|
|||||||
folders: selected_folders,
|
folders: selected_folders,
|
||||||
files: selected_files,
|
files: selected_files,
|
||||||
subject: "#{@project.name} #{l(:label_dmsf_file_plural).downcase}",
|
subject: "#{@project.name} #{l(:label_dmsf_file_plural).downcase}",
|
||||||
from: Setting.plugin_redmine_dmsf['dmsf_documents_email_from'].presence ||
|
from: RedmineDmsf.dmsf_documents_email_from,
|
||||||
"#{User.current.name} <#{User.current.mail}>",
|
reply_to: RedmineDmsf.dmsf_documents_email_reply_to
|
||||||
reply_to: Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
|
|
||||||
}
|
}
|
||||||
@back_url = params[:back_url]
|
@back_url = params[:back_url]
|
||||||
render action: 'email_entries'
|
render action: 'email_entries'
|
||||||
@ -583,7 +582,7 @@ class DmsfController < ApplicationController
|
|||||||
|
|
||||||
zip.add_dmsf_file file, member, file.dmsf_folder&.dmsf_path_str
|
zip.add_dmsf_file file, member, file.dmsf_folder&.dmsf_path_str
|
||||||
end
|
end
|
||||||
max_files = Setting.plugin_redmine_dmsf['dmsf_max_file_download'].to_i
|
max_files = RedmineDmsf.dmsf_max_file_download
|
||||||
raise RedmineDmsf::Errors::DmsfZipMaxFilesError if max_files.positive? && zip.dmsf_files.length > max_files
|
raise RedmineDmsf::Errors::DmsfZipMaxFilesError if max_files.positive? && zip.dmsf_files.length > max_files
|
||||||
|
|
||||||
zip
|
zip
|
||||||
@ -647,8 +646,8 @@ class DmsfController < ApplicationController
|
|||||||
unless deleted_files.empty?
|
unless deleted_files.empty?
|
||||||
begin
|
begin
|
||||||
recipients = DmsfMailer.deliver_files_deleted(@project, deleted_files)
|
recipients = DmsfMailer.deliver_files_deleted(@project, deleted_files)
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||||
max_receivers = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_receivers = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect { |user, _| user.name }.first(max_receivers).join(', ')
|
to = recipients.collect { |user, _| user.name }.first(max_receivers).join(', ')
|
||||||
if to.present?
|
if to.present?
|
||||||
to << (recipients.count > max_receivers ? ',...' : '.')
|
to << (recipients.count > max_receivers ? ',...' : '.')
|
||||||
|
|||||||
@ -77,8 +77,7 @@ class DmsfFilesController < ApplicationController
|
|||||||
# PDF preview
|
# PDF preview
|
||||||
pdf_preview = (params[:disposition] != 'attachment') && params[:filename].blank? && @file.pdf_preview
|
pdf_preview = (params[:disposition] != 'attachment') && params[:filename].blank? && @file.pdf_preview
|
||||||
filename = filename_for_content_disposition(@revision.formatted_name(member))
|
filename = filename_for_content_disposition(@revision.formatted_name(member))
|
||||||
if !api_request? && pdf_preview.present? && (Setting.plugin_redmine_dmsf['office_bin'].present? ||
|
if !api_request? && pdf_preview.present? && (RedmineDmsf.office_bin.present? || params[:preview].present?)
|
||||||
params[:preview].present?)
|
|
||||||
basename = File.basename(filename, '.*')
|
basename = File.basename(filename, '.*')
|
||||||
send_file pdf_preview, filename: "#{basename}.pdf", type: 'application/pdf', disposition: 'inline'
|
send_file pdf_preview, filename: "#{basename}.pdf", type: 'application/pdf', disposition: 'inline'
|
||||||
# Text preview
|
# Text preview
|
||||||
@ -181,8 +180,8 @@ class DmsfFilesController < ApplicationController
|
|||||||
call_hook :dmsf_helper_upload_after_commit, { file: @file }
|
call_hook :dmsf_helper_upload_after_commit, { file: @file }
|
||||||
begin
|
begin
|
||||||
recipients = DmsfMailer.deliver_files_updated(@project, [@file])
|
recipients = DmsfMailer.deliver_files_updated(@project, [@file])
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||||
max_notifications = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_notifications = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect { |user, _| user.name }.first(max_notifications).join(', ')
|
to = recipients.collect { |user, _| user.name }.first(max_notifications).join(', ')
|
||||||
if to.present?
|
if to.present?
|
||||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||||
@ -224,8 +223,8 @@ class DmsfFilesController < ApplicationController
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
recipients = DmsfMailer.deliver_files_deleted(@project, [@file])
|
recipients = DmsfMailer.deliver_files_deleted(@project, [@file])
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||||
max_notification = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_notification = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect { |user, _| user.name }.first(max_notification).join(', ')
|
to = recipients.collect { |user, _| user.name }.first(max_notification).join(', ')
|
||||||
if to.present?
|
if to.present?
|
||||||
to << (recipients.count > max_notification ? ',...' : '.')
|
to << (recipients.count > max_notification ? ',...' : '.')
|
||||||
|
|||||||
@ -39,9 +39,7 @@ class DmsfStateController < ApplicationController
|
|||||||
else
|
else
|
||||||
flash[:warning] = l(:user_is_not_project_member)
|
flash[:warning] = l(:user_is_not_project_member)
|
||||||
end
|
end
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable']
|
@project.update(dmsf_act_as_attachable: params[:act_as_attachable]) if RedmineDmsf.dmsf_act_as_attachable?
|
||||||
@project.update dmsf_act_as_attachable: params[:act_as_attachable]
|
|
||||||
end
|
|
||||||
@project.update default_dmsf_query_id: params[:default_dmsf_query]
|
@project.update default_dmsf_query_id: params[:default_dmsf_query]
|
||||||
redirect_to settings_project_path(@project, tab: 'dmsf')
|
redirect_to settings_project_path(@project, tab: 'dmsf')
|
||||||
end
|
end
|
||||||
|
|||||||
@ -80,9 +80,7 @@ class DmsfWorkflowsController < ApplicationController
|
|||||||
if @dmsf_workflow.try_finish revision, action, (params[:step_action].to_i / 10)
|
if @dmsf_workflow.try_finish revision, action, (params[:step_action].to_i / 10)
|
||||||
if revision.dmsf_file
|
if revision.dmsf_file
|
||||||
begin
|
begin
|
||||||
unless Setting.plugin_redmine_dmsf['dmsf_keep_documents_locked']
|
revision.dmsf_file.unlock!(force_file_unlock_allowed: true) unless RedmineDmsf.dmsf_keep_documents_locked?
|
||||||
revision.dmsf_file.unlock!(force_file_unlock_allowed: true)
|
|
||||||
end
|
|
||||||
rescue RedmineDmsf::Errors::DmsfLockError => e
|
rescue RedmineDmsf::Errors::DmsfLockError => e
|
||||||
flash[:info] = e.message
|
flash[:info] = e.message
|
||||||
end
|
end
|
||||||
@ -99,8 +97,8 @@ class DmsfWorkflowsController < ApplicationController
|
|||||||
:text_email_finished_approved,
|
:text_email_finished_approved,
|
||||||
:text_email_to_see_history
|
:text_email_to_see_history
|
||||||
)
|
)
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.present?
|
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.present?
|
||||||
max_notifications = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_notifications = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
||||||
if to.present?
|
if to.present?
|
||||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||||
@ -122,8 +120,8 @@ class DmsfWorkflowsController < ApplicationController
|
|||||||
:text_email_to_see_history,
|
:text_email_to_see_history,
|
||||||
action.note
|
action.note
|
||||||
)
|
)
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.present?
|
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.present?
|
||||||
max_notifications = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_notifications = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
||||||
if to.present?
|
if to.present?
|
||||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||||
@ -146,7 +144,7 @@ class DmsfWorkflowsController < ApplicationController
|
|||||||
action.note,
|
action.note,
|
||||||
action.dmsf_workflow_step_assignment.dmsf_workflow_step
|
action.dmsf_workflow_step_assignment.dmsf_workflow_step
|
||||||
)
|
)
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
if RedmineDmsf.dmsf_display_notified_recipients?
|
||||||
flash[:warning] = l(:warning_email_notifications, to: delegate.name)
|
flash[:warning] = l(:warning_email_notifications, to: delegate.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -186,13 +184,13 @@ class DmsfWorkflowsController < ApplicationController
|
|||||||
:text_email_to_see_status
|
:text_email_to_see_status
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
if RedmineDmsf.dmsf_display_notified_recipients?
|
||||||
recipients = assignments.collect(&:user)
|
recipients = assignments.collect(&:user)
|
||||||
recipients << to if to
|
recipients << to if to
|
||||||
recipients.uniq!
|
recipients.uniq!
|
||||||
recipients &= DmsfMailer.get_notify_users(@project, revision.dmsf_file, force_notification: true)
|
recipients &= DmsfMailer.get_notify_users(@project, revision.dmsf_file, force_notification: true)
|
||||||
unless recipients.empty?
|
unless recipients.empty?
|
||||||
max_notifications = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_notifications = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
||||||
if to.present?
|
if to.present?
|
||||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||||
|
|||||||
@ -140,8 +140,8 @@ module DmsfUploadHelper
|
|||||||
# Notifications
|
# Notifications
|
||||||
begin
|
begin
|
||||||
recipients = DmsfMailer.deliver_files_updated(project, files)
|
recipients = DmsfMailer.deliver_files_updated(project, files)
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||||
max_recipients = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_recipients = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect { |user, _| user.name }.first(max_recipients).join(', ')
|
to = recipients.collect { |user, _| user.name }.first(max_recipients).join(', ')
|
||||||
if to.present?
|
if to.present?
|
||||||
to << (recipients.count > max_recipients ? ',...' : '.')
|
to << (recipients.count > max_recipients ? ',...' : '.')
|
||||||
|
|||||||
@ -101,13 +101,10 @@ class DmsfFile < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.storage_path
|
def self.storage_path
|
||||||
path = Setting.plugin_redmine_dmsf['dmsf_storage_directory'].try(:strip)
|
path = RedmineDmsf.dmsf_storage_directory
|
||||||
if path.blank?
|
pn = Pathname.new(path)
|
||||||
path = Pathname.new('files').join('dmsf').to_s
|
return pn if pn.absolute?
|
||||||
else
|
|
||||||
pn = Pathname.new(path)
|
|
||||||
return pn if pn.absolute?
|
|
||||||
end
|
|
||||||
Rails.root.join path
|
Rails.root.join path
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -120,7 +117,7 @@ class DmsfFile < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def approval_allowed_zero_minor
|
def approval_allowed_zero_minor
|
||||||
Setting.plugin_redmine_dmsf['only_approval_zero_minor_version'] ? last_revision.minor_version&.zero? : true
|
RedmineDmsf.only_approval_zero_minor_version? ? last_revision.minor_version&.zero? : true
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_revision
|
def last_revision
|
||||||
@ -369,16 +366,8 @@ class DmsfFile < ApplicationRecord
|
|||||||
if !options[:titles_only] && RedmineDmsf::Plugin.xapian_available?
|
if !options[:titles_only] && RedmineDmsf::Plugin.xapian_available?
|
||||||
database = nil
|
database = nil
|
||||||
begin
|
begin
|
||||||
unless Setting.plugin_redmine_dmsf['dmsf_stemming_lang']
|
lang = RedmineDmsf.dmsf_stemming_lang.strip
|
||||||
raise StandardError, "'dmsf_stemming_lang' option is not set"
|
databasepath = File.join(RedmineDmsf.dmsf_index_database.strip, lang)
|
||||||
end
|
|
||||||
|
|
||||||
lang = Setting.plugin_redmine_dmsf['dmsf_stemming_lang'].strip
|
|
||||||
unless Setting.plugin_redmine_dmsf['dmsf_index_database']
|
|
||||||
raise StandardError, "'dmsf_index_database' option is not set"
|
|
||||||
end
|
|
||||||
|
|
||||||
databasepath = File.join(Setting.plugin_redmine_dmsf['dmsf_index_database'].strip, lang)
|
|
||||||
database = Xapian::Database.new(databasepath)
|
database = Xapian::Database.new(databasepath)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.error "REDMINE_XAPIAN ERROR: Xapian database is not properly set, initiated or it's corrupted."
|
Rails.logger.error "REDMINE_XAPIAN ERROR: Xapian database is not properly set, initiated or it's corrupted."
|
||||||
@ -397,7 +386,7 @@ class DmsfFile < ApplicationRecord
|
|||||||
qp.stemmer = stemmer
|
qp.stemmer = stemmer
|
||||||
qp.database = database
|
qp.database = database
|
||||||
|
|
||||||
case Setting.plugin_redmine_dmsf['dmsf_stemming_strategy'].strip
|
case RedmineDmsf.dmsf_stemming_strategy.strip
|
||||||
when 'STEM_NONE'
|
when 'STEM_NONE'
|
||||||
qp.stemming_strategy = Xapian::QueryParser::STEM_NONE
|
qp.stemming_strategy = Xapian::QueryParser::STEM_NONE
|
||||||
when 'STEM_SOME'
|
when 'STEM_SOME'
|
||||||
@ -413,7 +402,7 @@ class DmsfFile < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
flags = Xapian::QueryParser::FLAG_WILDCARD
|
flags = Xapian::QueryParser::FLAG_WILDCARD
|
||||||
flags |= Xapian::QueryParser::FLAG_CJK_NGRAM if Setting.plugin_redmine_dmsf['dmsf_enable_cjk_ngrams']
|
flags |= Xapian::QueryParser::FLAG_CJK_NGRAM if RedmineDmsf.dmsf_enable_cjk_ngrams?
|
||||||
|
|
||||||
query = qp.parse_query(query_string, flags)
|
query = qp.parse_query(query_string, flags)
|
||||||
|
|
||||||
|
|||||||
@ -325,7 +325,7 @@ class DmsfFileRevision < ApplicationRecord
|
|||||||
format = if member&.dmsf_title_format.present?
|
format = if member&.dmsf_title_format.present?
|
||||||
member.dmsf_title_format
|
member.dmsf_title_format
|
||||||
else
|
else
|
||||||
Setting.plugin_redmine_dmsf['dmsf_global_title_format']
|
RedmineDmsf.dmsf_global_title_format
|
||||||
end
|
end
|
||||||
return name if format.blank?
|
return name if format.blank?
|
||||||
|
|
||||||
|
|||||||
@ -371,9 +371,7 @@ class DmsfFolder < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.column_on?(column)
|
def self.column_on?(column)
|
||||||
dmsf_columns = Setting.plugin_redmine_dmsf['dmsf_columns']
|
RedmineDmsf.dmsf_columns.include? column
|
||||||
dmsf_columns ||= DmsfFolder::DEFAULT_COLUMNS
|
|
||||||
dmsf_columns.include? column
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_value(custom_field)
|
def custom_value(custom_field)
|
||||||
@ -385,8 +383,7 @@ class DmsfFolder < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.get_column_position(column)
|
def self.get_column_position(column)
|
||||||
dmsf_columns = Setting.plugin_redmine_dmsf['dmsf_columns']
|
dmsf_columns = RedmineDmsf.dmsf_columns
|
||||||
dmsf_columns ||= DmsfFolder::DEFAULT_COLUMNS
|
|
||||||
pos = 0
|
pos = 0
|
||||||
# 0 - checkbox
|
# 0 - checkbox
|
||||||
# 1 - id
|
# 1 - id
|
||||||
@ -545,7 +542,7 @@ class DmsfFolder < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.visible_folders(folders, project)
|
def self.visible_folders(folders, project)
|
||||||
allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
allowed = RedmineDmsf.dmsf_act_as_attachable? &&
|
||||||
(project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) &&
|
(project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) &&
|
||||||
User.current.allowed_to?(:display_system_folders, project)
|
User.current.allowed_to?(:display_system_folders, project)
|
||||||
folders.reject do |folder|
|
folders.reject do |folder|
|
||||||
|
|||||||
@ -258,7 +258,7 @@ class DmsfQuery < Query
|
|||||||
return query if query&.visibility == VISIBILITY_PUBLIC
|
return query if query&.visibility == VISIBILITY_PUBLIC
|
||||||
|
|
||||||
# Global default
|
# Global default
|
||||||
if (query_id = Setting.plugin_redmine_dmsf['dmsf_default_query']).present?
|
if (query_id = RedmineDmsf.dmsf_default_query).present?
|
||||||
query = find_by(id: query_id)
|
query = find_by(id: query_id)
|
||||||
return query if query&.visibility == VISIBILITY_PUBLIC
|
return query if query&.visibility == VISIBILITY_PUBLIC
|
||||||
end
|
end
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class DmsfUpload
|
|||||||
@tempfile_path = ''
|
@tempfile_path = ''
|
||||||
@token = ''
|
@token = ''
|
||||||
@digest = ''
|
@digest = ''
|
||||||
if Setting.plugin_redmine_dmsf['empty_minor_version_by_default']
|
if RedmineDmsf.empty_minor_version_by_default?
|
||||||
@major_version = 1
|
@major_version = 1
|
||||||
@minor_version = nil
|
@minor_version = nil
|
||||||
else
|
else
|
||||||
@ -92,7 +92,7 @@ class DmsfUpload
|
|||||||
if file.nil? || file.last_revision.nil?
|
if file.nil? || file.last_revision.nil?
|
||||||
@title = DmsfFileRevision.filename_to_title(@name)
|
@title = DmsfFileRevision.filename_to_title(@name)
|
||||||
@description = uploaded[:comment]
|
@description = uploaded[:comment]
|
||||||
if Setting.plugin_redmine_dmsf['empty_minor_version_by_default']
|
if RedmineDmsf.empty_minor_version_by_default?
|
||||||
@major_version = 1
|
@major_version = 1
|
||||||
@minor_version = nil
|
@minor_version = nil
|
||||||
else
|
else
|
||||||
|
|||||||
@ -249,9 +249,9 @@ class DmsfWorkflow < ApplicationRecord
|
|||||||
nil,
|
nil,
|
||||||
assignments.first&.dmsf_workflow_step
|
assignments.first&.dmsf_workflow_step
|
||||||
)
|
)
|
||||||
return unless Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && controller && recipients.present?
|
return unless RedmineDmsf.dmsf_display_notified_recipients? && controller && recipients.present?
|
||||||
|
|
||||||
max_recipients = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
max_recipients = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||||
to = recipients.collect(&:name).first(max_recipients).join(', ')
|
to = recipients.collect(&:name).first(max_recipients).join(', ')
|
||||||
return if to.blank?
|
return if to.blank?
|
||||||
|
|
||||||
|
|||||||
@ -80,12 +80,12 @@
|
|||||||
|
|
||||||
<%= context_menu %>
|
<%= context_menu %>
|
||||||
|
|
||||||
<% if !@folder&.system && (@project || Setting.plugin_redmine_dmsf['dmsf_webdav'].present?) %>
|
<% if !@folder&.system && (@project || RedmineDmsf.dmsf_webdav?) %>
|
||||||
<% other_formats_links do |f| %>
|
<% other_formats_links do |f| %>
|
||||||
<% if @project %>
|
<% if @project %>
|
||||||
<%= f.link_to 'CSV', url: { action: :show, id: @project, folder_id: @folder, encoding: Encoding::UTF_8 } %>
|
<%= f.link_to 'CSV', url: { action: :show, id: @project, folder_id: @folder, encoding: Encoding::UTF_8 } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if Setting.plugin_redmine_dmsf['dmsf_webdav'].present? %>
|
<% if RedmineDmsf.dmsf_webdav? %>
|
||||||
<span>
|
<span>
|
||||||
<%= link_to 'WebDAV', webdav_url(@project, @folder), class: 'webdav' %>
|
<%= link_to 'WebDAV', webdav_url(@project, @folder), class: 'webdav' %>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@ -56,7 +56,7 @@
|
|||||||
<%= link_to 'Documents.zip', download_email_entries_path(id: @project, folder_id: @folder,
|
<%= link_to 'Documents.zip', download_email_entries_path(id: @project, folder_id: @folder,
|
||||||
path: @email_params[:zipped_content]) %>
|
path: @email_params[:zipped_content]) %>
|
||||||
<%= l(:label_or) %>
|
<%= l(:label_or) %>
|
||||||
<%= check_box_tag('email[links_only]', 1, Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only'],
|
<%= check_box_tag('email[links_only]', 1, RedmineDmsf.dmsf_documents_email_links_only?,
|
||||||
onchange: "$('#public_url').toggle($('#email_links_only').prop('checked'))")
|
onchange: "$('#public_url').toggle($('#email_links_only').prop('checked'))")
|
||||||
%>
|
%>
|
||||||
<%= l(:label_links_only) %>
|
<%= l(:label_links_only) %>
|
||||||
|
|||||||
@ -83,7 +83,7 @@
|
|||||||
method: :post, class: 'icon icon-email',
|
method: :post, class: 'icon icon-email',
|
||||||
data: { cy: "icon__email--dmsf_file_#{dmsf_file.id}" }, disabled: !email_allowed %>
|
data: { cy: "icon__email--dmsf_file_#{dmsf_file.id}" }, disabled: !email_allowed %>
|
||||||
</li>
|
</li>
|
||||||
<% if Setting.plugin_redmine_dmsf['dmsf_webdav'].present? %>
|
<% if RedmineDmsf.dmsf_webdav? %>
|
||||||
<li>
|
<li>
|
||||||
<% if dmsf_file.last_revision && dmsf_file.last_revision.protocol %>
|
<% if dmsf_file.last_revision && dmsf_file.last_revision.protocol %>
|
||||||
<% url = "#{dmsf_file.last_revision.protocol}:ofe|u|#{Setting.protocol.strip}://#{Setting.host_name.strip}/dmsf/webdav/#{Addressable::URI.escape(RedmineDmsf::Webdav::ProjectResource.create_project_name(dmsf_file.project))}/" %>
|
<% url = "#{dmsf_file.last_revision.protocol}:ofe|u|#{Setting.protocol.strip}://#{Setting.host_name.strip}/dmsf/webdav/#{Addressable::URI.escape(RedmineDmsf::Webdav::ProjectResource.create_project_name(dmsf_file.project))}/" %>
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<% classes = 'hol' unless Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only'] %>
|
<% classes = 'hol' unless RedmineDmsf.dmsf_documents_email_links_only? %>
|
||||||
<span id="public_url" class="<%= classes %>">
|
<span id="public_url" class="<%= classes %>">
|
||||||
<%= check_box_tag 'email[public_urls]', 1, false %> <%= l(:label_public_urls) %>
|
<%= check_box_tag 'email[public_urls]', 1, false %> <%= l(:label_public_urls) %>
|
||||||
<%= date_field_tag('email[expired_at]', '', value: (DateTime.current + 3.days).to_date, size: 10) +
|
<%= date_field_tag('email[expired_at]', '', value: (DateTime.current + 3.days).to_date, size: 10) +
|
||||||
|
|||||||
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
<fieldset class="box tabular">
|
<fieldset class="box tabular">
|
||||||
<legend><%= l(:field_project) %> <%= l(:label_preferences) %></legend>
|
<legend><%= l(:field_project) %> <%= l(:label_preferences) %></legend>
|
||||||
<% if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] %>
|
<% if RedmineDmsf.dmsf_act_as_attachable? %>
|
||||||
<p>
|
<p>
|
||||||
<%= content_tag(:label, "#{l(:label_act_as_attachable)}:") %>
|
<%= content_tag(:label, "#{l(:label_act_as_attachable)}:") %>
|
||||||
<%= select_tag 'act_as_attachable',
|
<%= select_tag 'act_as_attachable',
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p><%= pref_fields.check_box :receive_download_notification %></p>
|
<p><%= pref_fields.check_box :receive_download_notification %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest' %>
|
<% if RedmineDmsf.dmsf_webdav_authentication == 'Digest' %>
|
||||||
<p>
|
<p>
|
||||||
<label for='webdav_digest_reset'><%= l(:label_dmsf_webdav_digest) %></label>
|
<label for='webdav_digest_reset'><%= l(:label_dmsf_webdav_digest) %></label>
|
||||||
<% token = Token.find_by(user_id: @user.id, action: 'dmsf_webdav_digest') %>
|
<% token = Token.find_by(user_id: @user.id, action: 'dmsf_webdav_digest') %>
|
||||||
|
|||||||
@ -141,7 +141,7 @@ begin
|
|||||||
|
|
||||||
# Indexing documents
|
# Indexing documents
|
||||||
stem_langs.each do |lang|
|
stem_langs.each do |lang|
|
||||||
filespath = Setting.plugin_redmine_dmsf['dmsf_storage_directory'] || File.join(REDMINE_ROOT, FILES)
|
filespath = RedmineDmsf.dmsf_storage_directory
|
||||||
unless File.directory?(filespath)
|
unless File.directory?(filespath)
|
||||||
warn "'#{filespath}' doesn't exist."
|
warn "'#{filespath}' doesn't exist."
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
2
init.rb
2
init.rb
@ -56,7 +56,7 @@ Redmine::Plugin.register :redmine_dmsf do
|
|||||||
'dmsf_webdav_use_project_names' => use_project_names,
|
'dmsf_webdav_use_project_names' => use_project_names,
|
||||||
'dmsf_webdav_ignore_1b_file_for_authentication' => '1',
|
'dmsf_webdav_ignore_1b_file_for_authentication' => '1',
|
||||||
'dmsf_projects_as_subfolders' => nil,
|
'dmsf_projects_as_subfolders' => nil,
|
||||||
'only_approval_zero_minor_version' => '0',
|
'only_approval_zero_minor_version' => nil,
|
||||||
'dmsf_max_notification_receivers_info' => 10,
|
'dmsf_max_notification_receivers_info' => 10,
|
||||||
'office_bin' => 'libreoffice',
|
'office_bin' => 'libreoffice',
|
||||||
'dmsf_global_menu_disabled' => nil,
|
'dmsf_global_menu_disabled' => nil,
|
||||||
|
|||||||
@ -18,6 +18,180 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Main module
|
||||||
|
module RedmineDmsf
|
||||||
|
# Settings
|
||||||
|
class << self
|
||||||
|
def dmsf_max_file_download
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_max_file_download'].to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_max_email_filesize
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_max_email_filesize'].to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_storage_directory
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_storage_directory'].presence || 'files/dmsf'
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_index_database
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_index_database'].presence || File.expand_path('dmsf_index', Rails.root)
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_stemming_lang
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_stemming_lang'].presence || 'english'
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_stemming_strategy
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_stemming_strategy'].presence || 'STEM_NONE'
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_webdav?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_webdav'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_display_notified_recipients?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_global_title_format
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_global_title_format'].presence || ''
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_columns
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_columns'].presence || DmsfFolder::DEFAULT_COLUMNS
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_webdav_ignore
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav_ignore'].presence || '^(\._|\.DS_Store$|Thumbs.db$)'
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_webdav_disable_versioning
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav_disable_versioning'].presence || '^\~\$|\.tmp$'
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_keep_documents_locked?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_keep_documents_locked'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_keep_documents_locked']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_keep_documents_locked'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_act_as_attachable?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable?'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable?']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable?'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_documents_email_from
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_documents_email_from'].presence || "#{User.current.name} <#{User.current.mail}>"
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_documents_email_reply_to
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to'].presence || ''
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_documents_email_links_only?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_enable_cjk_ngrams?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_enable_cjk_ngrams'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_enable_cjk_ngrams']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_enable_cjk_ngrams'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_webdav_use_project_names?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_webdav_ignore_1b_file_for_authentication?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_projects_as_subfolders?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def only_approval_zero_minor_version?
|
||||||
|
if Setting.plugin_redmine_dmsf['only_approval_zero_minor_version'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['only_approval_zero_minor_version']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['only_approval_zero_minor_version'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_max_notification_receivers_info
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].positive?
|
||||||
|
end
|
||||||
|
|
||||||
|
def office_bin
|
||||||
|
Setting.plugin_redmine_dmsf['office_bin'].presence || ''
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_global_menu_disabled?
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_global_menu_disabled'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_global_menu_disabled']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_global_menu_disabled'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_default_query
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_default_query'].presence || ''
|
||||||
|
end
|
||||||
|
|
||||||
|
def empty_minor_version_by_default?
|
||||||
|
if Setting.plugin_redmine_dmsf['empty_minor_version_by_default'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['empty_minor_version_by_default']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['empty_minor_version_by_default'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_original_documents_module?
|
||||||
|
if Setting.plugin_redmine_dmsf['remove_original_documents_module'].is_a?(TrueClass)
|
||||||
|
Setting.plugin_redmine_dmsf['remove_original_documents_module']
|
||||||
|
else
|
||||||
|
Setting.plugin_redmine_dmsf['remove_original_documents_module'].to_i.positive?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dmsf_webdav_authentication
|
||||||
|
Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'].presence || 'Basic'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# DMSF libraries
|
# DMSF libraries
|
||||||
|
|
||||||
# Validators
|
# Validators
|
||||||
|
|||||||
@ -28,7 +28,7 @@ module RedmineDmsf
|
|||||||
if message.present?
|
if message.present?
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
super(l(:error_max_email_filesize_exceeded, number: Setting.plugin_redmine_dmsf['dmsf_max_email_filesize']))
|
super(l(:error_max_email_filesize_exceeded, number: RedmineDmsf.dmsf_max_email_filesize))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,7 +28,7 @@ module RedmineDmsf
|
|||||||
if message.present?
|
if message.present?
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
super(l(:error_max_files_exceeded, number: Setting.plugin_redmine_dmsf['dmsf_max_file_download']))
|
super(l(:error_max_files_exceeded, number: RedmineDmsf.dmsf_max_file_download))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -32,7 +32,7 @@ module RedmineDmsf
|
|||||||
user = context[:user]
|
user = context[:user]
|
||||||
return unless user
|
return unless user
|
||||||
|
|
||||||
return unless Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest'
|
return unless RedmineDmsf.dmsf_webdav_authentication == 'Digest'
|
||||||
|
|
||||||
# Updates user's DMSF WebDAV digest
|
# Updates user's DMSF WebDAV digest
|
||||||
if controller.params[:password].present?
|
if controller.params[:password].present?
|
||||||
|
|||||||
@ -114,7 +114,7 @@ module RedmineDmsf
|
|||||||
def allowed_to_attach_documents(container)
|
def allowed_to_attach_documents(container)
|
||||||
container.respond_to?(:saved_dmsf_attachments) && container.project &&
|
container.respond_to?(:saved_dmsf_attachments) && container.project &&
|
||||||
User.current.allowed_to?(:file_manipulation, container.project) &&
|
User.current.allowed_to?(:file_manipulation, container.project) &&
|
||||||
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
RedmineDmsf.dmsf_act_as_attachable? &&
|
||||||
(container.project&.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
|
(container.project&.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ module RedmineDmsf
|
|||||||
links = []
|
links = []
|
||||||
if defined?(container.dmsf_files) &&
|
if defined?(container.dmsf_files) &&
|
||||||
User.current.allowed_to?(:view_dmsf_files, container.project) &&
|
User.current.allowed_to?(:view_dmsf_files, container.project) &&
|
||||||
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
RedmineDmsf.dmsf_act_as_attachable? &&
|
||||||
container.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS
|
container.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS
|
||||||
container.dmsf_files.each do |dmsf_file|
|
container.dmsf_files.each do |dmsf_file|
|
||||||
links << [dmsf_file, nil, dmsf_file.created_at] if dmsf_file.last_revision
|
links << [dmsf_file, nil, dmsf_file.created_at] if dmsf_file.last_revision
|
||||||
|
|||||||
@ -34,7 +34,7 @@ module RedmineDmsf
|
|||||||
module ClassMethods
|
module ClassMethods
|
||||||
def available_project_modules
|
def available_project_modules
|
||||||
# Removes the original Documents from project's modules (replaced with DMSF)
|
# Removes the original Documents from project's modules (replaced with DMSF)
|
||||||
if Setting.plugin_redmine_dmsf['remove_original_documents_module']
|
if RedmineDmsf.remove_original_documents_module?
|
||||||
super.reject { |m| m == :documents }
|
super.reject { |m| m == :documents }
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
|||||||
@ -34,7 +34,7 @@ module RedmineDmsf
|
|||||||
module ClassMethods
|
module ClassMethods
|
||||||
def available_search_types
|
def available_search_types
|
||||||
# Removes the original Documents from searching (replaced with DMSF)
|
# Removes the original Documents from searching (replaced with DMSF)
|
||||||
if Setting.plugin_redmine_dmsf['remove_original_documents_module']
|
if RedmineDmsf.remove_original_documents_module?
|
||||||
super.reject { |t| t == 'documents' }
|
super.reject { |t| t == 'documents' }
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
|||||||
@ -39,7 +39,7 @@ module RedmineDmsf
|
|||||||
)
|
)
|
||||||
|
|
||||||
def initialize(path, request, response, options)
|
def initialize(path, request, response, options)
|
||||||
raise NotFound if Setting.plugin_redmine_dmsf['dmsf_webdav'].blank?
|
raise NotFound unless RedmineDmsf.dmsf_webdav?
|
||||||
|
|
||||||
@project = nil
|
@project = nil
|
||||||
@public_path = "#{options[:root_uri_path]}#{path}"
|
@public_path = "#{options[:root_uri_path]}#{path}"
|
||||||
@ -162,7 +162,7 @@ module RedmineDmsf
|
|||||||
def get_project(scope, name, parent_project)
|
def get_project(scope, name, parent_project)
|
||||||
prj = nil
|
prj = nil
|
||||||
scope = scope.where(parent_id: parent_project.id) if parent_project
|
scope = scope.where(parent_id: parent_project.id) if parent_project
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
|
if RedmineDmsf.dmsf_webdav_use_project_names?
|
||||||
if name =~ /^\[?.+ (\d+)\]?$/
|
if name =~ /^\[?.+ (\d+)\]?$/
|
||||||
prj = scope.find_by(id: Regexp.last_match(1))
|
prj = scope.find_by(id: Regexp.last_match(1))
|
||||||
# Check again whether it's really the project and not a folder with a number as a suffix
|
# Check again whether it's really the project and not a folder with a number as a suffix
|
||||||
|
|||||||
@ -33,7 +33,7 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def process
|
def process
|
||||||
return super unless Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest'
|
return super unless RedmineDmsf.dmsf_webdav_authentication == 'Digest'
|
||||||
|
|
||||||
status = skip_authorization? || authenticate ? process_action || OK : Dav4rack::HttpStatus::Unauthorized
|
status = skip_authorization? || authenticate ? process_action || OK : Dav4rack::HttpStatus::Unauthorized
|
||||||
rescue Dav4rack::HttpStatus::Status => e
|
rescue Dav4rack::HttpStatus::Status => e
|
||||||
@ -52,7 +52,7 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def authenticate
|
def authenticate
|
||||||
return super unless Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest'
|
return super unless RedmineDmsf.dmsf_webdav_authentication == 'Digest'
|
||||||
|
|
||||||
auth_header = request.authorization.to_s
|
auth_header = request.authorization.to_s
|
||||||
scheme = auth_header.split(' ', 2).first&.downcase
|
scheme = auth_header.split(' ', 2).first&.downcase
|
||||||
|
|||||||
@ -199,11 +199,11 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
raise Locked if file.locked_for_user?
|
raise Locked if file.locked_for_user?
|
||||||
|
|
||||||
pattern = Setting.plugin_redmine_dmsf['dmsf_webdav_disable_versioning']
|
pattern = RedmineDmsf.dmsf_webdav_disable_versioning
|
||||||
# Files that are not versioned should be destroyed
|
# Files that are not versioned should be destroyed
|
||||||
# Zero-sized files should be destroyed
|
# Zero-sized files should be destroyed
|
||||||
b = !file.last_revision || file.last_revision.size.zero?
|
b = !file.last_revision || file.last_revision.size.zero?
|
||||||
destroy = (pattern.present? && basename.match(pattern)) || b
|
destroy = basename.match(pattern) || b
|
||||||
if file.delete(commit: destroy)
|
if file.delete(commit: destroy)
|
||||||
DmsfMailer.deliver_files_deleted project, [file]
|
DmsfMailer.deliver_files_deleted project, [file]
|
||||||
NoContent
|
NoContent
|
||||||
@ -551,8 +551,7 @@ module RedmineDmsf
|
|||||||
if exist? # We're over-writing something, so ultimately a new revision
|
if exist? # We're over-writing something, so ultimately a new revision
|
||||||
f = file
|
f = file
|
||||||
# Disable versioning for file name patterns given in the plugin settings.
|
# Disable versioning for file name patterns given in the plugin settings.
|
||||||
pattern = Setting.plugin_redmine_dmsf['dmsf_webdav_disable_versioning']
|
if basename.match(RedmineDmsf.dmsf_webdav_disable_versioning)
|
||||||
if pattern.present? && basename.match(pattern)
|
|
||||||
Rails.logger.info "Versioning disabled for #{basename}"
|
Rails.logger.info "Versioning disabled for #{basename}"
|
||||||
reuse_revision = true
|
reuse_revision = true
|
||||||
end
|
end
|
||||||
@ -611,8 +610,7 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Ignore 1b files sent for authentication
|
# Ignore 1b files sent for authentication
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication'].present? &&
|
if RedmineDmsf.dmsf_webdav_ignore_1b_file_for_authentication? && new_revision.size == 1
|
||||||
new_revision.size == 1
|
|
||||||
Rails.logger.warn "1b file '#{basename}' sent for authentication ignored"
|
Rails.logger.warn "1b file '#{basename}' sent for authentication ignored"
|
||||||
return NoContent
|
return NoContent
|
||||||
end
|
end
|
||||||
@ -797,9 +795,7 @@ module RedmineDmsf
|
|||||||
|
|
||||||
def ignore?
|
def ignore?
|
||||||
# Ignore file name patterns given in the plugin settings
|
# Ignore file name patterns given in the plugin settings
|
||||||
pattern = Setting.plugin_redmine_dmsf['dmsf_webdav_ignore']
|
if basename.match(RedmineDmsf.dmsf_webdav_ignore)
|
||||||
pattern = /^(\._|\.DS_Store$|Thumbs.db$)/ if pattern.blank?
|
|
||||||
if basename.match(pattern)
|
|
||||||
Rails.logger.info "#{basename} ignored"
|
Rails.logger.info "#{basename} ignored"
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -31,7 +31,7 @@ module RedmineDmsf
|
|||||||
return @children unless project
|
return @children unless project
|
||||||
|
|
||||||
# Sub-projects
|
# Sub-projects
|
||||||
load_projects(project.children) if Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders']
|
load_projects(project.children) if RedmineDmsf.dmsf_projects_as_subfolders?
|
||||||
return @children unless project.module_enabled?(:dmsf)
|
return @children unless project.module_enabled?(:dmsf)
|
||||||
|
|
||||||
# Folders
|
# Folders
|
||||||
@ -118,7 +118,7 @@ module RedmineDmsf
|
|||||||
def self.create_project_name(prj)
|
def self.create_project_name(prj)
|
||||||
return unless prj
|
return unless prj
|
||||||
|
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
|
if RedmineDmsf.dmsf_webdav_use_project_names?
|
||||||
"[#{DmsfFolder.get_valid_title(prj.name)} #{prj.id}]"
|
"[#{DmsfFolder.get_valid_title(prj.name)} #{prj.id}]"
|
||||||
else
|
else
|
||||||
"[#{prj.identifier}]"
|
"[#{prj.identifier}]"
|
||||||
|
|||||||
@ -32,7 +32,7 @@ module RedmineDmsf
|
|||||||
# Check the settings cache for each request
|
# Check the settings cache for each request
|
||||||
Setting.check_cache
|
Setting.check_cache
|
||||||
# Return 404 - NotFound if WebDAV is not enabled
|
# Return 404 - NotFound if WebDAV is not enabled
|
||||||
raise NotFound unless Setting.plugin_redmine_dmsf['dmsf_webdav']
|
raise NotFound unless RedmineDmsf.dmsf_webdav?
|
||||||
|
|
||||||
super
|
super
|
||||||
rc = get_resource_class(path)
|
rc = get_resource_class(path)
|
||||||
|
|||||||
@ -344,7 +344,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
with_settings plugin_redmine_dmsf: { 'dmsf_documents_email_from' => 'karel.picman@kontron.com' } do
|
with_settings plugin_redmine_dmsf: { 'dmsf_documents_email_from' => 'karel.picman@kontron.com' } do
|
||||||
post "/projects/#{@project1.id}/dmsf/entries", params: { email_entries: true, ids: ["file-#{@file1.id}"] }
|
post "/projects/#{@project1.id}/dmsf/entries", params: { email_entries: true, ids: ["file-#{@file1.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_from']
|
assert_select "input:match('value', ?)", RedmineDmsf.dmsf_documents_email_from
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
with_settings plugin_redmine_dmsf: { 'dmsf_documents_email_reply_to' => 'karel.picman@kontron.com' } do
|
with_settings plugin_redmine_dmsf: { 'dmsf_documents_email_reply_to' => 'karel.picman@kontron.com' } do
|
||||||
post "/projects/#{@project1.id}/dmsf/entries", params: { email_entries: true, ids: ["file-#{@file1.id}"] }
|
post "/projects/#{@project1.id}/dmsf/entries", params: { email_entries: true, ids: ["file-#{@file1.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
|
assert_select "input:match('value', ?)", RedmineDmsf.dmsf_documents_email_reply_to
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user