Safer access to settings parameters values

This commit is contained in:
Karel Picman 2016-01-15 13:53:55 +01:00
parent 4a9db192bf
commit 53e7094097
2 changed files with 4 additions and 4 deletions

View File

@ -98,7 +98,7 @@ class DmsfFile < ActiveRecord::Base
def self.storage_path
unless @@storage_path.present?
@@storage_path = Setting.plugin_redmine_dmsf['dmsf_storage_directory'].strip
@@storage_path = Setting.plugin_redmine_dmsf['dmsf_storage_directory'].strip if Setting.plugin_redmine_dmsf['dmsf_storage_directory'].present?
@@storage_path = Pathname(Redmine::Configuration['attachments_storage_path']).join('dmsf') if @@storage_path.blank? && Redmine::Configuration['attachments_storage_path'].present?
@@storage_path = Rails.root.join('files/dmsf').to_s if @@storage_path.blank?
Dir.mkdir(@@storage_path) unless File.exists?(@@storage_path)
@ -437,4 +437,4 @@ class DmsfFile < ActiveRecord::Base
end
end
end
end

View File

@ -53,7 +53,7 @@
<p>
<%= content_tag(:label, "#{l(:label_file_storage_directory)}:") %>
<%
storage_dir = @settings['dmsf_storage_directory'].strip
storage_dir = @settings['dmsf_storage_directory'].strip if @settings['dmsf_storage_directory'].present?
storage_dir = "#{Rails.root}/files/dmsf" if storage_dir.blank?
%>
<%= text_field_tag 'settings[dmsf_storage_directory]', storage_dir, :size => 50 %>
@ -178,4 +178,4 @@
&nbsp;&nbsp;STEM_ALL: <%= l(:note_stem_all) %><br/>
<%= l(:note_stemming_applied) %>
</em>
</p>
</p>