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 {
|
||||
User.current.allowed_to?(:view_dmsf_folders, nil, global: true) &&
|
||||
ActiveRecord::Base.connection.data_source_exists?('settings') &&
|
||||
Setting.plugin_redmine_dmsf['dmsf_global_menu_disabled'].blank?
|
||||
!RedmineDmsf.dmsf_global_menu_disabled?
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ class DmsfContextMenusController < ApplicationController
|
||||
@unlockable = @allowed && @dmsf_file.unlockable? && (!@dmsf_file.locked_for_user? ||
|
||||
User.current.allowed_to?(:force_file_unlock, @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
|
||||
@locked = @dmsf_folder.locked?
|
||||
@project = @dmsf_folder.project
|
||||
|
||||
@ -83,7 +83,7 @@ class DmsfController < ApplicationController
|
||||
@notifications = Setting.notified_events.include?('dmsf_legacy_notifications')
|
||||
@query.dmsf_folder_id = @folder ? @folder.id : nil
|
||||
@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)
|
||||
render_404
|
||||
return
|
||||
@ -501,7 +501,7 @@ class DmsfController < ApplicationController
|
||||
zip_entries(zip, selected_folders, selected_files)
|
||||
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
|
||||
raise RedmineDmsf::Errors::DmsfEmailMaxFileSizeError
|
||||
end
|
||||
@ -527,9 +527,8 @@ class DmsfController < ApplicationController
|
||||
folders: selected_folders,
|
||||
files: selected_files,
|
||||
subject: "#{@project.name} #{l(:label_dmsf_file_plural).downcase}",
|
||||
from: Setting.plugin_redmine_dmsf['dmsf_documents_email_from'].presence ||
|
||||
"#{User.current.name} <#{User.current.mail}>",
|
||||
reply_to: Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
|
||||
from: RedmineDmsf.dmsf_documents_email_from,
|
||||
reply_to: RedmineDmsf.dmsf_documents_email_reply_to
|
||||
}
|
||||
@back_url = params[:back_url]
|
||||
render action: 'email_entries'
|
||||
@ -583,7 +582,7 @@ class DmsfController < ApplicationController
|
||||
|
||||
zip.add_dmsf_file file, member, file.dmsf_folder&.dmsf_path_str
|
||||
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
|
||||
|
||||
zip
|
||||
@ -647,8 +646,8 @@ class DmsfController < ApplicationController
|
||||
unless deleted_files.empty?
|
||||
begin
|
||||
recipients = DmsfMailer.deliver_files_deleted(@project, deleted_files)
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
||||
max_receivers = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
||||
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||
max_receivers = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||
to = recipients.collect { |user, _| user.name }.first(max_receivers).join(', ')
|
||||
if to.present?
|
||||
to << (recipients.count > max_receivers ? ',...' : '.')
|
||||
|
||||
@ -77,8 +77,7 @@ class DmsfFilesController < ApplicationController
|
||||
# PDF preview
|
||||
pdf_preview = (params[:disposition] != 'attachment') && params[:filename].blank? && @file.pdf_preview
|
||||
filename = filename_for_content_disposition(@revision.formatted_name(member))
|
||||
if !api_request? && pdf_preview.present? && (Setting.plugin_redmine_dmsf['office_bin'].present? ||
|
||||
params[:preview].present?)
|
||||
if !api_request? && pdf_preview.present? && (RedmineDmsf.office_bin.present? || params[:preview].present?)
|
||||
basename = File.basename(filename, '.*')
|
||||
send_file pdf_preview, filename: "#{basename}.pdf", type: 'application/pdf', disposition: 'inline'
|
||||
# Text preview
|
||||
@ -181,8 +180,8 @@ class DmsfFilesController < ApplicationController
|
||||
call_hook :dmsf_helper_upload_after_commit, { file: @file }
|
||||
begin
|
||||
recipients = DmsfMailer.deliver_files_updated(@project, [@file])
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
||||
max_notifications = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
||||
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||
max_notifications = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||
to = recipients.collect { |user, _| user.name }.first(max_notifications).join(', ')
|
||||
if to.present?
|
||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||
@ -224,8 +223,8 @@ class DmsfFilesController < ApplicationController
|
||||
else
|
||||
begin
|
||||
recipients = DmsfMailer.deliver_files_deleted(@project, [@file])
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
||||
max_notification = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
||||
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||
max_notification = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||
to = recipients.collect { |user, _| user.name }.first(max_notification).join(', ')
|
||||
if to.present?
|
||||
to << (recipients.count > max_notification ? ',...' : '.')
|
||||
|
||||
@ -39,9 +39,7 @@ class DmsfStateController < ApplicationController
|
||||
else
|
||||
flash[:warning] = l(:user_is_not_project_member)
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable']
|
||||
@project.update dmsf_act_as_attachable: params[:act_as_attachable]
|
||||
end
|
||||
@project.update(dmsf_act_as_attachable: params[:act_as_attachable]) if RedmineDmsf.dmsf_act_as_attachable?
|
||||
@project.update default_dmsf_query_id: params[:default_dmsf_query]
|
||||
redirect_to settings_project_path(@project, tab: 'dmsf')
|
||||
end
|
||||
|
||||
@ -80,9 +80,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
if @dmsf_workflow.try_finish revision, action, (params[:step_action].to_i / 10)
|
||||
if revision.dmsf_file
|
||||
begin
|
||||
unless Setting.plugin_redmine_dmsf['dmsf_keep_documents_locked']
|
||||
revision.dmsf_file.unlock!(force_file_unlock_allowed: true)
|
||||
end
|
||||
revision.dmsf_file.unlock!(force_file_unlock_allowed: true) unless RedmineDmsf.dmsf_keep_documents_locked?
|
||||
rescue RedmineDmsf::Errors::DmsfLockError => e
|
||||
flash[:info] = e.message
|
||||
end
|
||||
@ -99,8 +97,8 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_finished_approved,
|
||||
:text_email_to_see_history
|
||||
)
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.present?
|
||||
max_notifications = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
||||
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.present?
|
||||
max_notifications = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
||||
if to.present?
|
||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||
@ -122,8 +120,8 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_to_see_history,
|
||||
action.note
|
||||
)
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.present?
|
||||
max_notifications = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
||||
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.present?
|
||||
max_notifications = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||
to = recipients.collect(&:name).first(max_notifications).join(', ')
|
||||
if to.present?
|
||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||
@ -146,7 +144,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
action.note,
|
||||
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)
|
||||
end
|
||||
end
|
||||
@ -186,13 +184,13 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_to_see_status
|
||||
)
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
if RedmineDmsf.dmsf_display_notified_recipients?
|
||||
recipients = assignments.collect(&:user)
|
||||
recipients << to if to
|
||||
recipients.uniq!
|
||||
recipients &= DmsfMailer.get_notify_users(@project, revision.dmsf_file, force_notification: true)
|
||||
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(', ')
|
||||
if to.present?
|
||||
to << (recipients.count > max_notifications ? ',...' : '.')
|
||||
|
||||
@ -140,8 +140,8 @@ module DmsfUploadHelper
|
||||
# Notifications
|
||||
begin
|
||||
recipients = DmsfMailer.deliver_files_updated(project, files)
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] && recipients.any?
|
||||
max_recipients = Setting.plugin_redmine_dmsf['dmsf_max_notification_receivers_info'].to_i
|
||||
if RedmineDmsf.dmsf_display_notified_recipients? && recipients.any?
|
||||
max_recipients = RedmineDmsf.dmsf_max_notification_receivers_info
|
||||
to = recipients.collect { |user, _| user.name }.first(max_recipients).join(', ')
|
||||
if to.present?
|
||||
to << (recipients.count > max_recipients ? ',...' : '.')
|
||||
|
||||
@ -101,13 +101,10 @@ class DmsfFile < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.storage_path
|
||||
path = Setting.plugin_redmine_dmsf['dmsf_storage_directory'].try(:strip)
|
||||
if path.blank?
|
||||
path = Pathname.new('files').join('dmsf').to_s
|
||||
else
|
||||
path = RedmineDmsf.dmsf_storage_directory
|
||||
pn = Pathname.new(path)
|
||||
return pn if pn.absolute?
|
||||
end
|
||||
|
||||
Rails.root.join path
|
||||
end
|
||||
|
||||
@ -120,7 +117,7 @@ class DmsfFile < ApplicationRecord
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def last_revision
|
||||
@ -369,16 +366,8 @@ class DmsfFile < ApplicationRecord
|
||||
if !options[:titles_only] && RedmineDmsf::Plugin.xapian_available?
|
||||
database = nil
|
||||
begin
|
||||
unless Setting.plugin_redmine_dmsf['dmsf_stemming_lang']
|
||||
raise StandardError, "'dmsf_stemming_lang' option is not set"
|
||||
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)
|
||||
lang = RedmineDmsf.dmsf_stemming_lang.strip
|
||||
databasepath = File.join(RedmineDmsf.dmsf_index_database.strip, lang)
|
||||
database = Xapian::Database.new(databasepath)
|
||||
rescue StandardError => e
|
||||
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.database = database
|
||||
|
||||
case Setting.plugin_redmine_dmsf['dmsf_stemming_strategy'].strip
|
||||
case RedmineDmsf.dmsf_stemming_strategy.strip
|
||||
when 'STEM_NONE'
|
||||
qp.stemming_strategy = Xapian::QueryParser::STEM_NONE
|
||||
when 'STEM_SOME'
|
||||
@ -413,7 +402,7 @@ class DmsfFile < ApplicationRecord
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@ -325,7 +325,7 @@ class DmsfFileRevision < ApplicationRecord
|
||||
format = if member&.dmsf_title_format.present?
|
||||
member.dmsf_title_format
|
||||
else
|
||||
Setting.plugin_redmine_dmsf['dmsf_global_title_format']
|
||||
RedmineDmsf.dmsf_global_title_format
|
||||
end
|
||||
return name if format.blank?
|
||||
|
||||
|
||||
@ -371,9 +371,7 @@ class DmsfFolder < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.column_on?(column)
|
||||
dmsf_columns = Setting.plugin_redmine_dmsf['dmsf_columns']
|
||||
dmsf_columns ||= DmsfFolder::DEFAULT_COLUMNS
|
||||
dmsf_columns.include? column
|
||||
RedmineDmsf.dmsf_columns.include? column
|
||||
end
|
||||
|
||||
def custom_value(custom_field)
|
||||
@ -385,8 +383,7 @@ class DmsfFolder < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_column_position(column)
|
||||
dmsf_columns = Setting.plugin_redmine_dmsf['dmsf_columns']
|
||||
dmsf_columns ||= DmsfFolder::DEFAULT_COLUMNS
|
||||
dmsf_columns = RedmineDmsf.dmsf_columns
|
||||
pos = 0
|
||||
# 0 - checkbox
|
||||
# 1 - id
|
||||
@ -545,7 +542,7 @@ class DmsfFolder < ApplicationRecord
|
||||
end
|
||||
|
||||
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) &&
|
||||
User.current.allowed_to?(:display_system_folders, project)
|
||||
folders.reject do |folder|
|
||||
|
||||
@ -258,7 +258,7 @@ class DmsfQuery < Query
|
||||
return query if query&.visibility == VISIBILITY_PUBLIC
|
||||
|
||||
# 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)
|
||||
return query if query&.visibility == VISIBILITY_PUBLIC
|
||||
end
|
||||
|
||||
@ -56,7 +56,7 @@ class DmsfUpload
|
||||
@tempfile_path = ''
|
||||
@token = ''
|
||||
@digest = ''
|
||||
if Setting.plugin_redmine_dmsf['empty_minor_version_by_default']
|
||||
if RedmineDmsf.empty_minor_version_by_default?
|
||||
@major_version = 1
|
||||
@minor_version = nil
|
||||
else
|
||||
@ -92,7 +92,7 @@ class DmsfUpload
|
||||
if file.nil? || file.last_revision.nil?
|
||||
@title = DmsfFileRevision.filename_to_title(@name)
|
||||
@description = uploaded[:comment]
|
||||
if Setting.plugin_redmine_dmsf['empty_minor_version_by_default']
|
||||
if RedmineDmsf.empty_minor_version_by_default?
|
||||
@major_version = 1
|
||||
@minor_version = nil
|
||||
else
|
||||
|
||||
@ -249,9 +249,9 @@ class DmsfWorkflow < ApplicationRecord
|
||||
nil,
|
||||
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(', ')
|
||||
return if to.blank?
|
||||
|
||||
|
||||
@ -80,12 +80,12 @@
|
||||
|
||||
<%= 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| %>
|
||||
<% if @project %>
|
||||
<%= f.link_to 'CSV', url: { action: :show, id: @project, folder_id: @folder, encoding: Encoding::UTF_8 } %>
|
||||
<% end %>
|
||||
<% if Setting.plugin_redmine_dmsf['dmsf_webdav'].present? %>
|
||||
<% if RedmineDmsf.dmsf_webdav? %>
|
||||
<span>
|
||||
<%= link_to 'WebDAV', webdav_url(@project, @folder), class: 'webdav' %>
|
||||
</span>
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
<%= link_to 'Documents.zip', download_email_entries_path(id: @project, folder_id: @folder,
|
||||
path: @email_params[:zipped_content]) %>
|
||||
<%= 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'))")
|
||||
%>
|
||||
<%= l(:label_links_only) %>
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
method: :post, class: 'icon icon-email',
|
||||
data: { cy: "icon__email--dmsf_file_#{dmsf_file.id}" }, disabled: !email_allowed %>
|
||||
</li>
|
||||
<% if Setting.plugin_redmine_dmsf['dmsf_webdav'].present? %>
|
||||
<% if RedmineDmsf.dmsf_webdav? %>
|
||||
<li>
|
||||
<% 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))}/" %>
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
# 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 %>">
|
||||
<%= 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) +
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
<fieldset class="box tabular">
|
||||
<legend><%= l(:field_project) %> <%= l(:label_preferences) %></legend>
|
||||
<% if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] %>
|
||||
<% if RedmineDmsf.dmsf_act_as_attachable? %>
|
||||
<p>
|
||||
<%= content_tag(:label, "#{l(:label_act_as_attachable)}:") %>
|
||||
<%= select_tag 'act_as_attachable',
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
</p>
|
||||
<p><%= pref_fields.check_box :receive_download_notification %></p>
|
||||
<% end %>
|
||||
<% if Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest' %>
|
||||
<% if RedmineDmsf.dmsf_webdav_authentication == 'Digest' %>
|
||||
<p>
|
||||
<label for='webdav_digest_reset'><%= l(:label_dmsf_webdav_digest) %></label>
|
||||
<% token = Token.find_by(user_id: @user.id, action: 'dmsf_webdav_digest') %>
|
||||
|
||||
@ -141,7 +141,7 @@ begin
|
||||
|
||||
# Indexing documents
|
||||
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)
|
||||
warn "'#{filespath}' doesn't exist."
|
||||
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_ignore_1b_file_for_authentication' => '1',
|
||||
'dmsf_projects_as_subfolders' => nil,
|
||||
'only_approval_zero_minor_version' => '0',
|
||||
'only_approval_zero_minor_version' => nil,
|
||||
'dmsf_max_notification_receivers_info' => 10,
|
||||
'office_bin' => 'libreoffice',
|
||||
'dmsf_global_menu_disabled' => nil,
|
||||
|
||||
@ -18,6 +18,180 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# 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
|
||||
|
||||
# Validators
|
||||
|
||||
@ -28,7 +28,7 @@ module RedmineDmsf
|
||||
if message.present?
|
||||
super
|
||||
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
|
||||
|
||||
@ -28,7 +28,7 @@ module RedmineDmsf
|
||||
if message.present?
|
||||
super
|
||||
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
|
||||
|
||||
@ -32,7 +32,7 @@ module RedmineDmsf
|
||||
user = context[: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
|
||||
if controller.params[:password].present?
|
||||
|
||||
@ -114,7 +114,7 @@ module RedmineDmsf
|
||||
def allowed_to_attach_documents(container)
|
||||
container.respond_to?(:saved_dmsf_attachments) && 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)
|
||||
end
|
||||
|
||||
@ -128,7 +128,7 @@ module RedmineDmsf
|
||||
links = []
|
||||
if defined?(container.dmsf_files) &&
|
||||
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.dmsf_files.each do |dmsf_file|
|
||||
links << [dmsf_file, nil, dmsf_file.created_at] if dmsf_file.last_revision
|
||||
|
||||
@ -34,7 +34,7 @@ module RedmineDmsf
|
||||
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']
|
||||
if RedmineDmsf.remove_original_documents_module?
|
||||
super.reject { |m| m == :documents }
|
||||
else
|
||||
super
|
||||
|
||||
@ -34,7 +34,7 @@ module RedmineDmsf
|
||||
module ClassMethods
|
||||
def available_search_types
|
||||
# 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' }
|
||||
else
|
||||
super
|
||||
|
||||
@ -39,7 +39,7 @@ module RedmineDmsf
|
||||
)
|
||||
|
||||
def initialize(path, request, response, options)
|
||||
raise NotFound if Setting.plugin_redmine_dmsf['dmsf_webdav'].blank?
|
||||
raise NotFound unless RedmineDmsf.dmsf_webdav?
|
||||
|
||||
@project = nil
|
||||
@public_path = "#{options[:root_uri_path]}#{path}"
|
||||
@ -162,7 +162,7 @@ module RedmineDmsf
|
||||
def get_project(scope, name, parent_project)
|
||||
prj = nil
|
||||
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+)\]?$/
|
||||
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
|
||||
|
||||
@ -33,7 +33,7 @@ module RedmineDmsf
|
||||
end
|
||||
|
||||
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
|
||||
rescue Dav4rack::HttpStatus::Status => e
|
||||
@ -52,7 +52,7 @@ module RedmineDmsf
|
||||
end
|
||||
|
||||
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
|
||||
scheme = auth_header.split(' ', 2).first&.downcase
|
||||
|
||||
@ -199,11 +199,11 @@ module RedmineDmsf
|
||||
end
|
||||
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
|
||||
# Zero-sized files should be destroyed
|
||||
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)
|
||||
DmsfMailer.deliver_files_deleted project, [file]
|
||||
NoContent
|
||||
@ -551,8 +551,7 @@ module RedmineDmsf
|
||||
if exist? # We're over-writing something, so ultimately a new revision
|
||||
f = file
|
||||
# Disable versioning for file name patterns given in the plugin settings.
|
||||
pattern = Setting.plugin_redmine_dmsf['dmsf_webdav_disable_versioning']
|
||||
if pattern.present? && basename.match(pattern)
|
||||
if basename.match(RedmineDmsf.dmsf_webdav_disable_versioning)
|
||||
Rails.logger.info "Versioning disabled for #{basename}"
|
||||
reuse_revision = true
|
||||
end
|
||||
@ -611,8 +610,7 @@ module RedmineDmsf
|
||||
end
|
||||
|
||||
# Ignore 1b files sent for authentication
|
||||
if Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication'].present? &&
|
||||
new_revision.size == 1
|
||||
if RedmineDmsf.dmsf_webdav_ignore_1b_file_for_authentication? && new_revision.size == 1
|
||||
Rails.logger.warn "1b file '#{basename}' sent for authentication ignored"
|
||||
return NoContent
|
||||
end
|
||||
@ -797,9 +795,7 @@ module RedmineDmsf
|
||||
|
||||
def ignore?
|
||||
# Ignore file name patterns given in the plugin settings
|
||||
pattern = Setting.plugin_redmine_dmsf['dmsf_webdav_ignore']
|
||||
pattern = /^(\._|\.DS_Store$|Thumbs.db$)/ if pattern.blank?
|
||||
if basename.match(pattern)
|
||||
if basename.match(RedmineDmsf.dmsf_webdav_ignore)
|
||||
Rails.logger.info "#{basename} ignored"
|
||||
return true
|
||||
end
|
||||
|
||||
@ -31,7 +31,7 @@ module RedmineDmsf
|
||||
return @children unless project
|
||||
|
||||
# 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)
|
||||
|
||||
# Folders
|
||||
@ -118,7 +118,7 @@ module RedmineDmsf
|
||||
def self.create_project_name(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}]"
|
||||
else
|
||||
"[#{prj.identifier}]"
|
||||
|
||||
@ -32,7 +32,7 @@ module RedmineDmsf
|
||||
# Check the settings cache for each request
|
||||
Setting.check_cache
|
||||
# Return 404 - NotFound if WebDAV is not enabled
|
||||
raise NotFound unless Setting.plugin_redmine_dmsf['dmsf_webdav']
|
||||
raise NotFound unless RedmineDmsf.dmsf_webdav?
|
||||
|
||||
super
|
||||
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
|
||||
post "/projects/#{@project1.id}/dmsf/entries", params: { email_entries: true, ids: ["file-#{@file1.id}"] }
|
||||
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
|
||||
|
||||
@ -353,7 +353,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
||||
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}"] }
|
||||
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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user