diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index f87fed4c..acc0b6a2 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -61,7 +61,7 @@ class DmsfFilesController < ApplicationController # TODO: line bellow is to handle old instalations with errors in data handling @revision.name = @file.name - @revision_pages = Paginator.new self, @file.revisions.visible.count, params["per_page"] ? params["per_page"].to_i : 25, params["page"] + @revision_pages = Paginator.new self, @file.revisions.visible.count, params['per_page'] ? params['per_page'].to_i : 25, params['page'] render :layout => !request.xhr? end @@ -69,12 +69,12 @@ class DmsfFilesController < ApplicationController #TODO: don't create revision if nothing change def create_revision unless params[:dmsf_file_revision] - redirect_to :action => "show", :id => @file + redirect_to :action => 'show', :id => @file return end if @file.locked_for_user? flash[:error] = l(:error_file_is_locked) - redirect_to :action => "show", :id => @file + redirect_to :action => 'show', :id => @file else #TODO: validate folder_id @revision = DmsfFileRevision.new(params[:dmsf_file_revision]) @@ -86,8 +86,7 @@ class DmsfFilesController < ApplicationController @revision.user = User.current @revision.major_version = last_revision.major_version - @revision.minor_version = last_revision.minor_version - #@revision.workflow = last_revision.workflow + @revision.minor_version = last_revision.minor_version version = params[:version].to_i file_upload = params[:file_upload] if file_upload.nil? @@ -100,8 +99,7 @@ class DmsfFilesController < ApplicationController @revision.size = file_upload.size @revision.disk_filename = @revision.new_storage_filename @revision.mime_type = Redmine::MimeType.of(file_upload.original_filename) - end - #@revision.set_workflow(params[:dmsf_workflow_id], params[:commit]) + end @file.name = @revision.name @file.folder = @revision.folder @@ -109,14 +107,14 @@ class DmsfFilesController < ApplicationController if @revision.valid? && @file.valid? @revision.save! @revision.assign_workflow(params[:dmsf_workflow_id]) - unless file_upload.nil? + if file_upload @revision.copy_file_content(file_upload) end if @file.locked? && !@file.locks.empty? begin @file.unlock! - flash[:notice] = l(:notice_file_unlocked) + ", " + flash[:notice] = "#{l(:notice_file_unlocked)}, " rescue #Nothing to do here end @@ -124,44 +122,44 @@ class DmsfFilesController < ApplicationController @file.save! @file.reload - flash[:notice] = (flash[:notice].nil? ? "" : flash[:notice]) + l(:notice_file_revision_created) - log_activity("new revision") + flash[:notice] = (flash[:notice].nil? ? '' : flash[:notice]) + l(:notice_file_revision_created) + log_activity('new revision') begin DmsfMailer.files_updated(User.current, [@file]).deliver rescue ActionView::MissingTemplate => e Rails.logger.error "Could not send email notifications: #{e.message}" end - redirect_to :action => "show", :id => @file + redirect_to :action => 'show', :id => @file else - render :action => "show" + render :action => 'show' end end end def delete - if !@file.nil? + if @file if @file.delete flash[:notice] = l(:notice_file_deleted) - log_activity("deleted") + log_activity('deleted') DmsfMailer.files_deleted(User.current, [@file]).deliver else flash[:error] = l(:error_file_is_locked) end end - redirect_to :controller => "dmsf", :action => "show", :id => @project, :folder_id => @file.folder + redirect_to :controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @file.folder end def delete_revision - if !@revision.nil? && !@revision.deleted + if @revision && !@revision.deleted if @revision.delete flash[:notice] = l(:notice_revision_deleted) - log_activity("deleted") + log_activity('deleted') else # TODO: check this error handling @revision.errors.each {|e,msg| flash[:error] = msg} end end - redirect_to :action => "show", :id => @file + redirect_to :action => 'show', :id => @file end def lock @@ -172,11 +170,11 @@ class DmsfFilesController < ApplicationController flash[:notice] = l(:notice_file_locked) end redirect_to params[:current] ? params[:current] : - {:controller => "dmsf", :action => "show", :id => @project, :folder_id => @file.folder} + {:controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @file.folder} end def unlock - if !@file.locked? + unless @file.locked? flash[:warning] = l(:warning_file_not_locked) else if @file.locks[0].user == User.current || User.current.allowed_to?(:force_file_unlock, @file.project) @@ -187,7 +185,7 @@ class DmsfFilesController < ApplicationController end end redirect_to params[:current] ? params[:current] : - {:controller => "dmsf", :action => "show", :id => @project, :folder_id => @file.folder} + {:controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @file.folder} end def notify_activate @@ -198,18 +196,18 @@ class DmsfFilesController < ApplicationController flash[:notice] = l(:notice_file_notifications_activated) end redirect_to params[:current] ? params[:current] : - {:controller => "dmsf", :action => "show", :id => @project, :folder_id => @file.folder} + {:controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @file.folder} end def notify_deactivate - if !@file.notification + unless @file.notification flash[:warning] = l(:warning_file_notifications_already_deactivated) else @file.notify_deactivate flash[:notice] = l(:notice_file_notifications_deactivated) end redirect_to params[:current] ? params[:current] : - {:controller => "dmsf", :action => "show", :id => @project, :folder_id => @file.folder} + {:controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @file.folder} end private @@ -219,14 +217,14 @@ class DmsfFilesController < ApplicationController end def send_revision - log_activity("downloaded") + log_activity('downloaded') access = DmsfFileRevisionAccess.new(:user_id => User.current.id, :dmsf_file_revision_id => @revision.id, :action => DmsfFileRevisionAccess::DownloadAction) access.save! send_file(@revision.disk_file, :filename => filename_for_content_disposition(@revision.name), :type => @revision.detect_content_type, - :disposition => "attachment") + :disposition => 'attachment') end def find_file @@ -242,7 +240,7 @@ class DmsfFilesController < ApplicationController end def check_project(entry) - if !entry.nil? && entry.project != @project + if entry && entry.project != @project raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project) end end diff --git a/app/controllers/dmsf_files_copy_controller.rb b/app/controllers/dmsf_files_copy_controller.rb index 016d0402..ecfb3a4f 100644 --- a/app/controllers/dmsf_files_copy_controller.rb +++ b/app/controllers/dmsf_files_copy_controller.rb @@ -52,30 +52,30 @@ class DmsfFilesCopyController < ApplicationController raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project) end - if (!@target_folder.nil? && @target_folder == @file.folder) || + if (@target_folder && @target_folder == @file.folder) || (@target_folder.nil? && @file.folder.nil? && @target_project == @file.project) flash[:error] = l(:error_target_folder_same) - redirect_to :action => "new", :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder + redirect_to :action => 'new', :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder return end new_file = @file.copy_to(@target_project, @target_folder) unless new_file.errors.empty? - flash[:error] = "#{l(:error_file_cannot_be_copied)}: #{new_file.errors.full_messages.join(", ")}" - redirect_to :action => "new", :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder + flash[:error] = "#{l(:error_file_cannot_be_copied)}: #{new_file.errors.full_messages.join(', ')}" + redirect_to :action => 'new', :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder return end flash[:notice] = l(:notice_file_copied) - log_activity(new_file, "was copied (is copy)") + log_activity(new_file, 'was copied (is copy)') begin DmsfMailer.files_updated(User.current, [new_file]).deliver rescue ActionView::MissingTemplate => e Rails.logger.error "Could not send email notifications: #{e.message}" end - redirect_to :controller => "dmsf_files", :action => "show", :id => new_file + redirect_to :controller => 'dmsf_files', :action => 'show', :id => new_file end def move @@ -85,27 +85,27 @@ class DmsfFilesCopyController < ApplicationController return end @target_folder = DmsfFolder.visible.find(params[:target_folder_id]) unless params[:target_folder_id].blank? - if !@target_folder.nil? && @target_folder.project != @target_project + if @target_folder && @target_folder.project != @target_project raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project) end - if (!@target_folder.nil? && @target_folder == @file.folder) || + if (@target_folder && @target_folder == @file.folder) || (@target_folder.nil? && @file.folder.nil? && @target_project == @file.project) flash[:error] = l(:error_target_folder_same) - redirect_to :action => "new", :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder + redirect_to :action => 'new', :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder return end unless @file.move_to(@target_project, @target_folder) - flash[:error] = "#{l(:error_file_cannot_be_moved)}: #{@file.errors.full_messages.join(", ")}" - redirect_to :action => "new", :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder + flash[:error] = "#{l(:error_file_cannot_be_moved)}: #{@file.errors.full_messages.join(', ')}" + redirect_to :action => 'new', :id => @file, :target_project_id => @target_project, :target_folder_id => @target_folder return end @file.reload flash[:notice] = l(:notice_file_moved) - log_activity(@file, "was moved (is copy)") + log_activity(@file, 'was moved (is copy)') begin # TODO: implement proper mail notification DmsfMailer.files_updated(User.current, [@file]).deliver @@ -113,7 +113,7 @@ class DmsfFilesCopyController < ApplicationController Rails.logger.error "Could not send email notifications: #{e.message}" end - redirect_to :controller => "dmsf_files", :action => "show", :id => @file + redirect_to :controller => 'dmsf_files', :action => 'show', :id => @file end private diff --git a/app/controllers/dmsf_folders_copy_controller.rb b/app/controllers/dmsf_folders_copy_controller.rb index 19697e35..d5e3306d 100644 --- a/app/controllers/dmsf_folders_copy_controller.rb +++ b/app/controllers/dmsf_folders_copy_controller.rb @@ -24,8 +24,6 @@ class DmsfFoldersCopyController < ApplicationController before_filter :find_folder before_filter :authorize -# verify :method => :post, :only => [:copy_to], :render => { :nothing => true, :status => :method_not_allowed } - def new @target_project = DmsfFolder.allowed_target_projects_on_copy.detect {|p| p.id.to_s == params[:target_project_id]} if params[:target_project_id] @target_project ||= @project if User.current.allowed_to?(:folder_manipulation, @project) @@ -52,25 +50,25 @@ class DmsfFoldersCopyController < ApplicationController raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project) end - if (!@target_folder.nil? && @target_folder == @folder.folder) || + if (@target_folder && @target_folder == @folder.folder) || (@target_folder.nil? && @folder.folder.nil? && @target_project == @folder.project) flash[:error] = l(:error_target_folder_same) - redirect_to :action => "new", :id => @folder, :target_project_id => @target_project, :target_folder_id => @target_folder + redirect_to :action => 'new', :id => @folder, :target_project_id => @target_project, :target_folder_id => @target_folder return end new_folder = @folder.copy_to(@target_project, @target_folder) unless new_folder.errors.empty? - flash[:error] = "#{l(:error_folder_cannot_be_copied)}: #{new_folder.errors.full_messages.join(", ")}" - redirect_to :action => "new", :id => @folder, :target_project_id => @target_project, :target_folder_id => @target_folder + flash[:error] = "#{l(:error_folder_cannot_be_copied)}: #{new_folder.errors.full_messages.join(', ')}" + redirect_to :action => 'new', :id => @folder, :target_project_id => @target_project, :target_folder_id => @target_folder return end new_folder.reload flash[:notice] = l(:notice_folder_copied) - log_activity(new_folder, "was copied (is copy)") + log_activity(new_folder, 'was copied (is copy)') #TODO: implement proper notification for all new files #begin @@ -79,7 +77,7 @@ class DmsfFoldersCopyController < ApplicationController # Rails.logger.error "Could not send email notifications: " + e #end - redirect_to :controller => "dmsf", :action => "show", :id => @target_project, :folder_id => new_folder + redirect_to :controller => 'dmsf', :action => 'show', :id => @target_project, :folder_id => new_folder end private diff --git a/app/controllers/dmsf_state_controller.rb b/app/controllers/dmsf_state_controller.rb index b1dd41f8..ef292491 100644 --- a/app/controllers/dmsf_state_controller.rb +++ b/app/controllers/dmsf_state_controller.rb @@ -35,7 +35,7 @@ class DmsfStateController < ApplicationController else flash[:warning] = l(:user_is_not_project_member) end - redirect_to :controller => "projects", :action => 'settings', :tab => 'dmsf', :id => @project + redirect_to :controller => 'projects', :action => 'settings', :tab => 'dmsf', :id => @project end private @@ -45,7 +45,7 @@ class DmsfStateController < ApplicationController end def check_project(entry) - if !entry.nil? && entry.project != @project + if entry && entry.project != @project raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project) end end diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index d85e8557..db3ef456 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -55,7 +55,7 @@ class DmsfUploadController < ApplicationController return end @disk_filename = DmsfHelper.temp_filename(@tempfile.original_filename) - File.open("#{DmsfHelper.temp_dir}/#{@disk_filename}", "wb") do |f| + File.open("#{DmsfHelper.temp_dir}/#{@disk_filename}", 'wb') do |f| while (buffer = @tempfile.read(8192)) f.write(buffer) end @@ -65,7 +65,7 @@ class DmsfUploadController < ApplicationController File.delete("#{DmsfHelper.temp_dir}/#{@disk_filename}") rescue end - render :layout => nil, :json => { :jsonrpc => "2.0", + render :layout => nil, :json => { :jsonrpc => '2.0', :error => { :code => 103, :message => l(:header_minimum_filesize), diff --git a/app/helpers/dmsf_helper.rb b/app/helpers/dmsf_helper.rb index a70628d2..384b4229 100644 --- a/app/helpers/dmsf_helper.rb +++ b/app/helpers/dmsf_helper.rb @@ -16,8 +16,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require "tmpdir" -require "digest/md5" +require 'tmpdir' +require 'digest/md5' module DmsfHelper @@ -72,7 +72,7 @@ module DmsfHelper # Why can't Mysql::Time conform to time object? - without a utc? method it breaks redmine's # rendering method, so we convert it to string, and back into time - not the most efficient # of methods - however seems functional. Not sure if MySQL - return obj.to_s.to_time(ActiveRecord::Base.default_timezone) if obj.class.name == "Mysql::Time" + return obj.to_s.to_time(ActiveRecord::Base.default_timezone) if obj.class.name == 'Mysql::Time' return obj end diff --git a/app/models/dmsf_file_revision_access.rb b/app/models/dmsf_file_revision_access.rb index 4bc7ba5e..e644d250 100644 --- a/app/models/dmsf_file_revision_access.rb +++ b/app/models/dmsf_file_revision_access.rb @@ -18,7 +18,7 @@ class DmsfFileRevisionAccess < ActiveRecord::Base unloadable - belongs_to :revision, :class_name => "DmsfFileRevision", :foreign_key => "dmsf_file_revision_id" + belongs_to :revision, :class_name => 'DmsfFileRevision', :foreign_key => 'dmsf_file_revision_id' belongs_to :user DownloadAction = 0 diff --git a/app/models/dmsf_lock.rb b/app/models/dmsf_lock.rb index 2e308fe8..c58f59d9 100644 --- a/app/models/dmsf_lock.rb +++ b/app/models/dmsf_lock.rb @@ -19,8 +19,8 @@ class DmsfLock < ActiveRecord::Base before_create :generate_uuid - belongs_to :file, :class_name => "DmsfFile", :foreign_key => "entity_id" - belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "entity_id" + belongs_to :file, :class_name => 'DmsfFile', :foreign_key => 'entity_id' + belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'entity_id' belongs_to :user #At the moment apparently we're only supporting a write lock? @@ -68,6 +68,5 @@ class DmsfLock < ActiveRecord::Base def self.find_by_param(*args) self.find(*args) end - end diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 7b0bd73c..5d3d9ed3 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require "mailer" +require 'mailer' class DmsfMailer < Mailer @@ -31,29 +31,29 @@ class DmsfMailer < Mailer @project = project mail :to => get_notify_user_emails(user, files), - :subject => project.name + ": Dmsf files updated" + :subject => "#{project.name}: Dmsf files updated" end def files_deleted(user, files) project = files[0].project files = files.select { |file| file.notify? } - redmine_headers "Project" => project.identifier + redmine_headers 'Project' => project.identifier @user = user @files = files @project = project mail :to => get_notify_user_emails(user, files), - :subject => project.name + ": Dmsf files deleted" + :subject => "#{project.name}: Dmsf files deleted" end def send_documents(user, email_to, email_cc, email_subject, zipped_content, email_plain_body) - zipped_content_data = open(zipped_content, "rb") {|io| io.read } + zipped_content_data = open(zipped_content, 'rb') {|io| io.read } @body = email_plain_body - attachments['Documents.zip'] = {:content_type => "application/zip", :content => zipped_content_data} + attachments['Documents.zip'] = {:content_type => 'application/zip', :content => zipped_content_data} mail(:to => email_to, :cc => email_cc, :subject => email_subject, :from => user.mail) end diff --git a/app/views/dmsf/_multi_upload.html.erb b/app/views/dmsf/_multi_upload.html.erb index 9331b77c..79157aee 100644 --- a/app/views/dmsf/_multi_upload.html.erb +++ b/app/views/dmsf/_multi_upload.html.erb @@ -18,142 +18,140 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%>
- <%= form_tag({:controller => "dmsf_upload", :action => "upload_files", :id => @project, :folder_id => @folder}, - :id => "uploadform", :method=>:post, :multipart => true) do %> -<% if Setting.attachment_max_size.to_i >= 102400 %> -
- <%= l(:label_file_size) %>: -
-<% end %> -

<%= l(:heading_file_upload) %>

-
- - <% max_file_upload = Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i %> - <%= l(:note_uploaded_maximum_files_at_once, :number => max_file_upload) if max_file_upload > 0 %> - <%= l(:note_upload_files_greater_than_two_gb) if Setting.attachment_max_size.to_i >= 2097151 %> - -
-
-

- -<%= file_field_tag("uploaded_files[1]", :size => 30, :id => nil) %> - -
-<%= link_to(l(:label_add_another_file), "#", :onclick => "dmsfAddFileField(); return false;" ) %> -(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) - -

-<%= submit_tag(l(:submit_upload_files)) %> -
-<% end %> + <%= form_tag({:controller => 'dmsf_upload', :action => 'upload_files', :id => @project, :folder_id => @folder}, + :id => 'uploadform', :method=>:post, :multipart => true) do %> + <% if Setting.attachment_max_size.to_i >= 102400 %> +
+ <%= l(:label_file_size) %>: +
+ <% end %> +

<%= l(:heading_file_upload) %>

+
+ + <% max_file_upload = Setting.plugin_redmine_dmsf['dmsf_max_file_upload'].to_i %> + <%= l(:note_uploaded_maximum_files_at_once, :number => max_file_upload) if max_file_upload > 0 %> + <%= l(:note_upload_files_greater_than_two_gb) if Setting.attachment_max_size.to_i >= 2097151 %> + +
+
+

+ + <%= file_field_tag('uploaded_files[1]', :size => 30, :id => nil) %> + +
+ <%= link_to(l(:label_add_another_file), '#', :onclick => 'dmsfAddFileField(); return false;' ) %> + (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + +

+ <%= submit_tag(l(:submit_upload_files)) %> +
+ <% end %>
<% content_for :header_tags do %> - <%= javascript_include_tag "bowser.min.js", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "plupload/plupload.js", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "plupload/plupload.flash.js", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "plupload/plupload.html5.js", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "plupload/plupload.html4.js", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "plupload/jquery.ui.plupload/jquery.ui.plupload.js", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag("plupload/i18n/#{I18n.locale.to_s.downcase}.js", :plugin => "redmine_dmsf") if I18n.locale && !I18n.locale.to_s.match(/^en.*/) %> - - -<% end %> + <%= javascript_include_tag 'bowser.min.js', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'plupload/plupload.js', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'plupload/plupload.flash.js', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'plupload/plupload.html5.js', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'plupload/plupload.html4.js', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag('plupload/i18n/#{I18n.locale.to_s.downcase}.js', :plugin => 'redmine_dmsf') if I18n.locale && !I18n.locale.to_s.match(/^en.*/) %> + + +<% end %> \ No newline at end of file diff --git a/app/views/dmsf/edit.html.erb b/app/views/dmsf/edit.html.erb index c82c00d8..ef6cf8a1 100644 --- a/app/views/dmsf/edit.html.erb +++ b/app/views/dmsf/edit.html.erb @@ -20,12 +20,12 @@ <% html_title(l(:dmsf)) %>
- <%= link_to(image_tag("copy.png"), {:controller => :dmsf_folders_copy, :action => "new", :id => @folder }, :title => l(:title_copy)) unless @folder.id.nil? %> + <%= link_to(image_tag('copy.png'), + {:controller => :dmsf_folders_copy, :action => 'new', :id => @folder }, + :title => l(:title_copy)) if @folder.id %>
-<% - create = @pathfolder == @parent -%> +<% create = @pathfolder == @parent %>

<% path = @pathfolder ? @pathfolder.dmsf_path : [] %> @@ -37,43 +37,43 @@ <%= "/ #{l(:heading_new_folder)}" if create %>

-<%= form_for(@folder, :url => {:action => create ? "create" : "save", :id => @project, :folder_id => @folder, :parent_id => @parent}, - :html => {:method=>:post}) do |f| %> - <%= error_messages_for(@folder) %> -
-
-
-

- <%= label_tag("dmsf_folder_title", l(:label_title) + ":") %> - <%= f.text_field(:title, :size => "32", :required => true) %> -

-
-
-

- <%= label_tag("", l(:field_folder) + ":") %> - <%= f.select(:dmsf_folder_id, - options_for_select(DmsfFolder.directory_tree(@project, @folder), - :selected => @parent? @parent.id : (@pathfolder.id if @pathfolder))) - %> -

-
-
-

- <%= label_tag("dmsf_folder_description", l(:label_description) + ":") %> -

-
- <%= f.text_area(:description, :rows => 15, :class => "wiki-edit") %> -
- <% values = @folder ? @folder.custom_field_values : @parent ? @parent.custom_field_values : DmsfFolder.new(:project => @project).custom_field_values %> - <% values.each do |value| %> -

<%= custom_field_tag_with_label(:dmsf_folder, value) %>

- <% end %> -
- <%= submit_tag(create ? l(:submit_create) : l(:submit_save)) %> +<%= form_for(@folder, :url => {:action => create ? 'create' : 'save', :id => @project, :folder_id => @folder, :parent_id => @parent}, + :html => {:method=>:post}) do |f| %> + <%= error_messages_for(@folder) %> +
+
+
+

+ <%= label_tag('dmsf_folder_title', "#{l(:label_title)}:") %> + <%= f.text_field(:title, :size => '32', :required => true) %> +

+
+
+

+ <%= label_tag('', "#{l(:field_folder)}:") %> + <%= f.select(:dmsf_folder_id, + options_for_select(DmsfFolder.directory_tree(@project, @folder), + :selected => @parent? @parent.id : (@pathfolder.id if @pathfolder))) + %> +

+
+
+

+ <%= label_tag('dmsf_folder_description', "#{l(:label_description)}:") %> +

+
+ <%= f.text_area(:description, :rows => 15, :class => 'wiki-edit') %> +
+ <% values = @folder ? @folder.custom_field_values : @parent ? @parent.custom_field_values : DmsfFolder.new(:project => @project).custom_field_values %> + <% values.each do |value| %> +

<%= custom_field_tag_with_label(:dmsf_folder, value) %>

+ <% end %> +
+ <%= submit_tag(create ? l(:submit_create) : l(:submit_save)) %> <% end %> -<%= wikitoolbar_for "dmsf_folder_description" %> +<%= wikitoolbar_for 'dmsf_folder_description' %> <% content_for :header_tags do %> - <%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %> + <%= stylesheet_link_tag 'dmsf', :plugin => 'redmine_dmsf' %> <% end %> diff --git a/app/views/dmsf/email_entries.html.erb b/app/views/dmsf/email_entries.html.erb index 632acb9a..a01a92a4 100644 --- a/app/views/dmsf/email_entries.html.erb +++ b/app/views/dmsf/email_entries.html.erb @@ -33,34 +33,34 @@

<%= l(:heading_send_documents_by_email) %>

-<%= form_tag({:action => "entries_email", :id => @project, :folder_id => @folder}, - { :method=>:post, :class => "tabular"}) do %> -
-

- <%= label_tag("", l(:label_email_from) + ":") %> - <%= h(User.current.mail) %> -

-

- <%= label_tag("email[to]", l(:label_email_to) + ":") %> - <%= text_field_tag("email[to]", @email_params["to"], :style => "width: 90%;") %> -

-

- <%= label_tag("email[cc]", l(:label_email_cc) + ":") %> - <%= text_field_tag("email[cc]", @email_params["cc"], :style => "width: 90%;") %> -

-

- <%= label_tag("email[subject]", l(:label_email_subject) + ":") %> - <%= text_field_tag("email[subject]", @email_params["subject"], :style => "width: 90%;") %> -

-

- <%= label_tag("", l(:label_email_documents) + ":") %> - Documents.zip - <%= hidden_field_tag("email[zipped_content]", @email_params["zipped_content"]) %> -

-

- <%= label_tag("email[body]", l(:label_email_body) + ":") %> - <%= text_area_tag("email[body]", @email_params["body"], :rows=> "20", :style => "width: 90%;") %> -

-

<%= submit_tag(l(:label_email_send)) %>

-
+<%= form_tag({:action => 'entries_email', :id => @project, :folder_id => @folder}, + { :method=>:post, :class => 'tabular'}) do %> +
+

+ <%= label_tag('', "#{l(:label_email_from)}:") %> + <%= h(User.current.mail) %> +

+

+ <%= label_tag('email[to]', "#{l(:label_email_to)}:") %> + <%= text_field_tag('email[to]', @email_params['to'], :style => 'width: 90%;') %> +

+

+ <%= label_tag('email[cc]', "#{l(:label_email_cc)}:") %> + <%= text_field_tag('email[cc]', @email_params['cc'], :style => 'width: 90%;') %> +

+

+ <%= label_tag('email[subject]', "#{l(:label_email_subject)}:") %> + <%= text_field_tag('email[subject]', @email_params['subject'], :style => 'width: 90%;') %> +

+

+ <%= label_tag('', "#{l(:label_email_documents)}:") %> + Documents.zip + <%= hidden_field_tag('email[zipped_content]', @email_params['zipped_content']) %> +

+

+ <%= label_tag('email[body]', "#{l(:label_email_body)}:") %> + <%= text_area_tag('email[body]', @email_params['body'], :rows=> '20', :style => 'width: 90%;') %> +

+

<%= submit_tag(l(:label_email_send)) %>

+
<% end %> diff --git a/app/views/dmsf_files_copy/new.html.erb b/app/views/dmsf_files_copy/new.html.erb index 0cf8da89..0c3d096f 100644 --- a/app/views/dmsf_files_copy/new.html.erb +++ b/app/views/dmsf_files_copy/new.html.erb @@ -30,49 +30,47 @@ <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> <% end %> / - <%= link_to(h(@file.title), {:controller => "dmsf_files", :action => "show", :id=> @file}) %> - <%= image_tag("notify.png", :plugin => "redmine_dmsf", :title => l(:title_notifications_active)) if @file.notification %> + <%= link_to(h(@file.title), {:controller => 'dmsf_files', :action => 'show', :id=> @file}) %> + <%= image_tag('notify.png', :plugin => 'redmine_dmsf', :title => l(:title_notifications_active)) if @file.notification %> -<% unless DmsfFile.allowed_target_projects_on_copy.blank? %> - <%= form_tag({:action => "create", :id => @file}, :id => "copyForm") do |f| %> -
-

- - <%= select_tag("target_project_id", - project_tree_options_for_select(DmsfFile.allowed_target_projects_on_copy, :selected => @target_project)) %> -

-

- <%= label_tag("target_folder_id", l(:label_target_folder) + ":") %> - <%= select_tag("target_folder_id", - options_for_select(DmsfFolder.directory_tree(@target_project), - :selected => (@target_folder.id unless @target_folder.nil?))) %> -

-
- - - <%= submit_tag(l(:button_copy)) %> - <% if User.current.allowed_to?(:file_manipulation, @project) %> - - <% end %> - <% end %> +<% if DmsfFile.allowed_target_projects_on_copy.present? %> + <%= form_tag({:action => 'create', :id => @file}, :id => 'copyForm') do |f| %> +
+

+ + <%= select_tag('target_project_id', + project_tree_options_for_select(DmsfFile.allowed_target_projects_on_copy, :selected => @target_project)) %> +

+

+ <%= label_tag('target_folder_id', "#{l(:label_target_folder)}:") %> + <%= select_tag('target_folder_id', + options_for_select(DmsfFolder.directory_tree(@target_project), + :selected => (@target_folder.id if @target_folder))) %> +

+
+ <%= submit_tag(l(:button_copy)) %> + <% if User.current.allowed_to?(:file_manipulation, @project) %> + + <% end %> + <% end %> <% end %> <% content_for :header_tags do %> - <%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "jquery-1.6.1.min.js", :plugin => "redmine_dmsf" %> - + <%= stylesheet_link_tag 'dmsf', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'jquery-1.6.1.min.js', :plugin => 'redmine_dmsf' %> + <% end %> diff --git a/app/views/dmsf_folders_copy/new.html.erb b/app/views/dmsf_folders_copy/new.html.erb index 500cf00a..9be97821 100644 --- a/app/views/dmsf_folders_copy/new.html.erb +++ b/app/views/dmsf_folders_copy/new.html.erb @@ -19,8 +19,7 @@ <% html_title(l(:dmsf)) %> -
-
+

<%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> @@ -31,35 +30,34 @@

<% unless DmsfFolder.allowed_target_projects_on_copy.blank? %> - <%= form_tag({:action => "copy_to", :id => @folder}, :id => "copyForm") do |f| %> -
-

- - <%= select_tag("target_project_id", - project_tree_options_for_select(DmsfFolder.allowed_target_projects_on_copy, :selected => @target_project)) %> -

-

- <%= label_tag("target_folder_id", l(:label_target_folder) + ":") %> - <%= select_tag("target_folder_id", - options_for_select(DmsfFolder.directory_tree(@target_project, @folder), - :selected => (@target_folder.id unless @target_folder.nil?))) %> -

-
- - <%= submit_tag(l(:button_copy)) %> - <% end %> + <%= form_tag({:action => 'copy_to', :id => @folder}, :id => 'copyForm') do |f| %> +
+

+ + <%= select_tag('target_project_id', + project_tree_options_for_select(DmsfFolder.allowed_target_projects_on_copy, :selected => @target_project)) %> +

+

+ <%= label_tag('target_folder_id', "#{l(:label_target_folder)}:") %> + <%= select_tag('target_folder_id', + options_for_select(DmsfFolder.directory_tree(@target_project, @folder), + :selected => (@target_folder.id if @target_folder))) %> +

+
+ <%= submit_tag(l(:button_copy)) %> + <% end %> <% end %> <% content_for :header_tags do %> - <%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "jquery-1.6.1.min.js", :plugin => "redmine_dmsf" %> - + <%= stylesheet_link_tag 'dmsf', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'jquery-1.6.1.min.js', :plugin => 'redmine_dmsf' %> + <% end %> diff --git a/app/views/dmsf_mailer/files_updated.html.erb b/app/views/dmsf_mailer/files_updated.html.erb index c1f4e38f..ebe11c0a 100644 --- a/app/views/dmsf_mailer/files_updated.html.erb +++ b/app/views/dmsf_mailer/files_updated.html.erb @@ -17,21 +17,21 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -User <%= link_to(h(@user), {:only_path => false, :controller => "users", :action => "show", :id => @user }) %> +User <%= link_to(h(@user), {:only_path => false, :controller => 'users', :action => 'show', :id => @user }) %> actualized DMSF files in project <%= @project.name %>: <% @files.each do |file| %>

- <%= link_to(h(file.dmsf_path_str), - {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file, - :download => ""}) %> (<%= file.name %>), - <%= number_to_human_size(file.last_revision.size) %>, - version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>, - <%= "#{file.last_revision.workflow_str(true)}," unless file.last_revision.workflow_str(true).blank? %> - <%= link_to("Details", - {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %> - <% unless file.last_revision.comment.blank? %> -
    <%= h(file.last_revision.comment) %> - <% end %> + <%= link_to(h(file.dmsf_path_str), + {:only_path => false, :controller => 'dmsf_files', :action => 'show', :id => file, + :download => ''}) %> (<%= file.name %>), + <%= number_to_human_size(file.last_revision.size) %>, + version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>, + <%= "#{file.last_revision.workflow_str(true)}," if file.last_revision.workflow_str(true).present? %> + <%= link_to('Details', + {:only_path => false, :controller => 'dmsf_files', :action => 'show', :id => file}) %> + <% if file.last_revision.comment.present? %> +
    <%= h(file.last_revision.comment) %> + <% end %>

<% end %> \ No newline at end of file diff --git a/app/views/dmsf_mailer/files_updated.text.erb b/app/views/dmsf_mailer/files_updated.text.erb index 35c87a3c..e05db87c 100644 --- a/app/views/dmsf_mailer/files_updated.text.erb +++ b/app/views/dmsf_mailer/files_updated.text.erb @@ -19,7 +19,7 @@ User <%= @user %> actualized DMSF files in project <%= @project.name %>: <% @files.each do |file| %> - <%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %><%= ", #{file.last_revision.workflow_str(true)}" unless file.last_revision.workflow_str(true).blank? %> - <%= url_for({:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %> - <% unless file.last_revision.comment.blank? %> comment: <%= file.last_revision.comment %><% end %> + <%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %><%= ", #{file.last_revision.workflow_str(true)}" unless file.last_revision.workflow_str(true).blank? %> + <%= url_for({:only_path => false, :controller => 'dmsf_files', :action => 'show', :id => file}) %> + <% if file.last_revision.comment.present? %> comment: <%= file.last_revision.comment %><% end %> <% end %> \ No newline at end of file diff --git a/app/views/dmsf_mailer/workflow_notification.html.erb b/app/views/dmsf_mailer/workflow_notification.html.erb index cd97bd32..fd759524 100644 --- a/app/views/dmsf_mailer/workflow_notification.html.erb +++ b/app/views/dmsf_mailer/workflow_notification.html.erb @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -

Dear <%= @user.name %>,

+

<%= @user.name %>,

<%= @text1 %>

diff --git a/app/views/dmsf_mailer/workflow_notification.text.erb b/app/views/dmsf_mailer/workflow_notification.text.erb index 87235d3a..17fa7989 100644 --- a/app/views/dmsf_mailer/workflow_notification.text.erb +++ b/app/views/dmsf_mailer/workflow_notification.text.erb @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -Dear <%= @user.name %> , +<%= @user.name %> , <%= @text1 %> <% unless @revision.folder %> <%= @text2 %> <%= url_for(:controller => 'dmsf', :action => 'show', :id => @revision.file.project, :only_path => false) %>. diff --git a/app/views/dmsf_upload/_upload_file_locked.html.erb b/app/views/dmsf_upload/_upload_file_locked.html.erb index 8248bbc8..10cdd406 100644 --- a/app/views/dmsf_upload/_upload_file_locked.html.erb +++ b/app/views/dmsf_upload/_upload_file_locked.html.erb @@ -18,45 +18,45 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%>
- <%= hidden_field_tag("commited_files[#{i}][disk_filename]", upload.disk_filename) %> - <%= hidden_field_tag("commited_files[#{i}][name]", upload.name) %> -

<%= l(:info_file_locked) %>

- -
-
-

- <%= label_tag("", l(:label_title) + ":") %> - <%= h(upload.title) %> -

-
-
-

- <%= label_tag("", l(:label_filename) + ":") %> - <%= h(upload.name) %> -

-
-
-

- <%= label_tag("", l(:label_description) + ":") %> -

-
- <%= textilizable(upload.description) %> -
-
-

- <%= label_tag("", l(:label_version) + ":") %> - <%= upload.major_version %>.<%= upload.minor_version %> -

-
-
-

- <%= label_tag("", l(:label_mime) + ":") %> - <%= h(upload.mime_type) %> -

-

- <%= label_tag("", l(:label_size) + ":") %> - <%= number_to_human_size(upload.size) %> -

-
-
+ <%= hidden_field_tag("commited_files[#{i}][disk_filename]", upload.disk_filename) %> + <%= hidden_field_tag("commited_files[#{i}][name]", upload.name) %> +

<%= l(:info_file_locked) %>

+ +
+
+

+ <%= label_tag('', "#{l(:label_title)}:") %> + <%= h(upload.title) %> +

+
+
+

+ <%= label_tag('', "#{l(:label_filename)}:") %> + <%= h(upload.name) %> +

+
+
+

+ <%= label_tag('', "#{l(:label_description)}:") %> +

+
+ <%= textilizable(upload.description) %> +
+
+

+ <%= label_tag('', "#{l(:label_version)}:") %> + <%= upload.major_version %>.<%= upload.minor_version %> +

+
+
+

+ <%= label_tag('', "#{l(:label_mime)}:") %> + <%= h(upload.mime_type) %> +

+

+ <%= label_tag('', "#{l(:label_size)}:") %> + <%= number_to_human_size(upload.size) %> +

+
+
diff --git a/app/views/dmsf_upload/upload_files.html.erb b/app/views/dmsf_upload/upload_files.html.erb index 13a5909c..3d02bf2c 100644 --- a/app/views/dmsf_upload/upload_files.html.erb +++ b/app/views/dmsf_upload/upload_files.html.erb @@ -37,26 +37,25 @@

<%=l(:heading_uploaded_files)%>

<% i = 1 %> -<%= form_tag({:action => "commit_files", :id => @project, :folder_id => @folder}, - :method=>:post) do %> - <% @uploads.each do |upload| %> - <% if upload.locked %> - <%= render(:partial => 'upload_file_locked', :locals => {:upload => upload, :i => i}) %> - <% else %> - <%= render(:partial => 'upload_file', :locals => {:upload => upload, :i => i}) %> - <% end %> - <% i += 1 %> - <% end %> - <%= submit_tag(l(:submit_commit)) %> +<%= form_tag({:action => 'commit_files', :id => @project, :folder_id => @folder}, + :method=>:post) do %> + <% @uploads.each do |upload| %> + <% if upload.locked %> + <%= render(:partial => 'upload_file_locked', :locals => {:upload => upload, :i => i}) %> + <% else %> + <%= render(:partial => 'upload_file', :locals => {:upload => upload, :i => i}) %> + <% end %> + <% i += 1 %> + <% end %> + <%= submit_tag(l(:submit_commit)) %> <% end %> <% content_for :header_tags do %> - <%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %> - <%= javascript_include_tag "jquery-1.6.1.min.js", :plugin => "redmine_dmsf" %> - + <%= stylesheet_link_tag 'dmsf', :plugin => 'redmine_dmsf' %> + <%= javascript_include_tag 'jquery-1.6.1.min.js', :plugin => 'redmine_dmsf' %> + <% end %> diff --git a/app/views/settings/_dmsf_settings.erb b/app/views/settings/_dmsf_settings.erb deleted file mode 100644 index d184c1ae..00000000 --- a/app/views/settings/_dmsf_settings.erb +++ /dev/null @@ -1,151 +0,0 @@ -<%# Redmine plugin for Document Management System "Features" -# -# Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2012 Daniel Munn -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> - -

- <%=content_tag(:label, l(:label_maximum_files_upload) + ":") %> - <%=text_field_tag "settings[dmsf_max_file_upload]", @settings["dmsf_max_file_upload"], :size=>10 %>
- (<%=l(:label_default)%>: 0) -
- <%= l(:note_maximum_number_of_files_uploaded) %> -

- -

- <%=content_tag(:label, l(:label_maximum_files_download) + ":") %> - <%=text_field_tag "settings[dmsf_max_file_download]", @settings["dmsf_max_file_download"], :size=>10 %>
- (<%=l(:label_default)%>: 0) -
- <%= l(:note_maximum_number_of_files_downloaded) %> -

- -

- <%=content_tag(:label, l(:label_maximum_email_filesize) + ":") %> - <%=text_field_tag "settings[dmsf_max_email_filesize]", @settings["dmsf_max_email_filesize"], :size=>10 %>
- (<%=l(:label_default)%>: 0) -
- <%= l(:note_maximum_email_filesize) %> -

- -

- <%=content_tag(:label, l(:label_file_storage_directory) + ":") %> - <% - storage_dir = @settings["dmsf_storage_directory"].strip - storage_dir = "#{Rails.root}/files/dmsf" if storage_dir.blank? - %> - <%=text_field_tag "settings[dmsf_storage_directory]", storage_dir, :size=>50 %>
- (<%=l(:label_default)%>: <%="#{Rails.root}/files/dmsf"%>) -

-<% unless File.exists?(storage_dir) - begin - Dir.mkdir(storage_dir) - rescue %> -

<%= l(:error_file_storage_directory_does_not_exist) %>

-<% end - end %> -<% testfilename = "#{storage_dir}/test.test" - if File.exists?(storage_dir) - begin - File.open(testfilename, "wb") do |file| - end - rescue %> -

<%= l(:error_file_can_not_be_created) %>

-<% ensure - File.delete(testfilename) if File.exists?(testfilename) - end - end %> - -

- <%=content_tag(:label, l(:label_physical_file_delete) + ":") %> - <%= check_box_tag("settings[dmsf_really_delete_files]", true, @settings["dmsf_really_delete_files"]) %>
- (<%=l(:label_default)%>: <%=l(:general_text_No)%>) -

- -

- <%=content_tag(:label, l(:label_default_notifications) + ":") %> - <%=select_tag("settings[dmsf_default_notifications]", - options_for_select([ - [l(:select_option_deactivated), nil], - [l(:select_option_activated), "1"]], - :selected => @settings["dmsf_default_notifications"])) %>
- (<%=l(:label_default)%>: <%=l(:select_option_deactivated)%>) -

- -

- <%=content_tag(:label, l(:label_webdav) + ":") %> - <%=select_tag("settings[dmsf_webdav]", - options_for_select([ - [l(:select_option_deactivated), nil], - [l(:select_option_activated), "1"]], - :selected => @settings["dmsf_webdav"])) %>
- (<%=l(:label_default)%>: <%=l(:select_option_activated)%>) -
- <%= l(:note_webdav).html_safe %> -

- -<% if @settings["dmsf_webdav"].nil? || !@settings["dmsf_webdav"].empty? %> -

- <%=content_tag(:label, l(:label_webdav_strategy) + ":") %> - <%=select_tag("settings[dmsf_webdav_strategy]", - options_for_select([ - [l(:select_option_webdav_readonly), "WEBDAV_READ_ONLY"], - [l(:select_option_webdav_readwrite), "WEBDAV_READ_WRITE"]], - :selected => @settings["dmsf_webdav_strategy"])) %>
- (<%=l(:label_default)%>: <%=l(:select_option_webdav_readonly)%>) -
- <%= l(:note_webdav_strategy).html_safe %> -

-<% end %> - - -
-<% begin - require 'xapian' - xapian_disabled = false - rescue LoadError %> -

<%= l(:warning_xapian_not_available) %>

-<% xapian_disabled = true - end %> - -

- <%=content_tag(:label, l(:label_index_database) + ":") %> - <%=text_field_tag 'settings[dmsf_index_database]', @settings['dmsf_index_database'], :disabled => xapian_disabled, :size=>50 %>
- (<%=l(:label_default)%>: <%="#{Rails.root}/files/dmsf_index"%>) -

- -

- <%=content_tag(:label, l(:label_stemming_language) + ":") %> - <%=text_field_tag 'settings[dmsf_stemming_lang]', @settings['dmsf_stemming_lang'], :disabled => xapian_disabled %>
- (<%=l(:label_default)%>: english )
-
- <%=l(:note_possible_values)%>: danish dutch english finnish french german german2 hungarian italian kraaij_pohlmann lovins norwegian porter portuguese romanian russian spanish swedish turkish (<%=l(:note_pass_none_to_disable_stemming)%>) -

- -

- <%=content_tag(:label, l(:label_stem_strategy) + ":")%> - <%=radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_NONE', @settings['dmsf_stemming_strategy'] == 'STEM_NONE', :disabled => xapian_disabled, :checked=>true %> <%=l(:option_stem_none)%>
- <%=radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_SOME', @settings['dmsf_stemming_strategy'] == 'STEM_SOME', :disabled => xapian_disabled %> <%=l(:option_stem_some)%>
- <%=radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_ALL', @settings['dmsf_stemming_strategy'] == 'STEM_ALL', :disabled => xapian_disabled %> <%=l(:option_stem_all)%>
-
- <%=l(:label_stemming_description)%>: -
- STEM_NONE: <%=l(:note_do_not_stem)%>
- STEM_SOME: <%=l(:note_stem_some)%>
- STEM_ALL: <%=l(:note_stem_all)%>
-
- <%=l(:note_stemming_applied)%>
-

diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb new file mode 100644 index 00000000..ebbfc1d3 --- /dev/null +++ b/app/views/settings/_dmsf_settings.html.erb @@ -0,0 +1,152 @@ +<%# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2012 Daniel Munn +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> + +

+ <%= content_tag(:label, "#{l(:label_maximum_files_upload)}:") %> + <%= text_field_tag 'settings[dmsf_max_file_upload]', @settings['dmsf_max_file_upload'], :size => 10 %>
+ (<%= l(:label_default) %>: 0) +
+ <%= l(:note_maximum_number_of_files_uploaded) %> +

+ +

+ <%= content_tag(:label, "#{l(:label_maximum_files_download)}:") %> + <%= text_field_tag 'settings[dmsf_max_file_download]', @settings['dmsf_max_file_download'], :size => 10 %>
+ (<%= l(:label_default) %>: 0) +
+ <%= l(:note_maximum_number_of_files_downloaded) %> +

+ +

+ <%= content_tag(:label, "#{l(:label_maximum_email_filesize)}:") %> + <%= text_field_tag 'settings[dmsf_max_email_filesize]', @settings['dmsf_max_email_filesize'], :size => 10 %>
+ (<%= l(:label_default) %>: 0) +
+ <%= l(:note_maximum_email_filesize) %> +

+ +

+ <%= content_tag(:label, "#{l(:label_file_storage_directory)}:") %> + <% + storage_dir = @settings['dmsf_storage_directory'].strip + storage_dir = "#{Rails.root}/files/dmsf" if storage_dir.blank? + %> + <%= text_field_tag 'settings[dmsf_storage_directory]', storage_dir, :size => 50 %>
+ (<%= l(:label_default) %>: <%= "#{Rails.root}/files/dmsf" %>) +

+<% unless File.exists?(storage_dir) %> + <% begin %> + <% Dir.mkdir(storage_dir) %> + <% rescue %> +

<%= l(:error_file_storage_directory_does_not_exist) %>

+ <% end %> +<% end %> +<% testfilename = "#{storage_dir}/test.test" %> +<% if File.exists?(storage_dir) %> + <% begin %> + <% File.open(testfilename, 'wb') do |file| %> + <% end %> + <% rescue %> +

<%= l(:error_file_can_not_be_created) %>

+ <% ensure %> + <% File.delete(testfilename) if File.exists?(testfilename) %> + <% end %> +<% end %> + +

+ <%= content_tag(:label, "#{l(:label_physical_file_delete)}:") %> + <%= check_box_tag('settings[dmsf_really_delete_files]', true, @settings['dmsf_really_delete_files']) %>
+ (<%=l(:label_default)%>: <%=l(:general_text_No)%>) +

+ +

+ <%= content_tag(:label, "#{l(:label_default_notifications)}:") %> + <%= select_tag('settings[dmsf_default_notifications]', + options_for_select([ + [l(:select_option_deactivated), nil], + [l(:select_option_activated), '1']], + :selected => @settings['dmsf_default_notifications'])) %>
+ (<%= l(:label_default) %>: <%= l(:select_option_deactivated) %>) +

+ +
+ +

+ <%= content_tag(:label, "#{l(:label_webdav)}:") %> + <%= select_tag('settings[dmsf_webdav]', + options_for_select([ + [l(:select_option_deactivated), nil], + [l(:select_option_activated), '1']], + :selected => @settings['dmsf_webdav'])) %>
+ (<%= l(:label_default) %>: <%= l(:select_option_activated) %>) +
+ <%= l(:note_webdav).html_safe %> +

+ +<% if @settings['dmsf_webdav'].nil? || !@settings['dmsf_webdav'].empty? %> +

+ <%= content_tag(:label, "#{l(:label_webdav_strategy)}:") %> + <%= select_tag('settings[dmsf_webdav_strategy]', + options_for_select([ + [l(:select_option_webdav_readonly), 'WEBDAV_READ_ONLY'], + [l(:select_option_webdav_readwrite), 'WEBDAV_READ_WRITE']], + :selected => @settings['dmsf_webdav_strategy'])) %>
+ (<%= l(:label_default) %>: <%= l(:select_option_webdav_readonly) %>) +
+ <%= l(:note_webdav_strategy).html_safe %> +

+<% end %> + +
+ +<% begin %> + <% require 'xapian' %> + <% xapian_disabled = false %> +<% rescue LoadError %> +

<%= l(:warning_xapian_not_available) %>

+ <% xapian_disabled = true %> +<% end %> + +

+ <%= content_tag(:label, "#{l(:label_index_database)}:") %> + <%= text_field_tag 'settings[dmsf_index_database]', @settings['dmsf_index_database'], :disabled => xapian_disabled, :size => 50 %>
+ (<%= l(:label_default) %>: <%= "#{Rails.root}/files/dmsf_index" %>) +

+ +

+ <%= content_tag(:label, "#{l(:label_stemming_language)}:") %> + <%= text_field_tag 'settings[dmsf_stemming_lang]', @settings['dmsf_stemming_lang'], :disabled => xapian_disabled %>
+ (<%= l(:label_default)%>: english )
+
+ <%= l(:note_possible_values)%>: danish dutch english finnish french german german2 hungarian italian kraaij_pohlmann lovins norwegian porter portuguese romanian russian spanish swedish turkish (<%= l(:note_pass_none_to_disable_stemming) %>)

+ +

+ <%= content_tag(:label, l(:label_stem_strategy) + ":")%> + <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_NONE', @settings['dmsf_stemming_strategy'] == 'STEM_NONE', :disabled => xapian_disabled, :checked=>true %> <%= l(:option_stem_none) %>
+ <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_SOME', @settings['dmsf_stemming_strategy'] == 'STEM_SOME', :disabled => xapian_disabled %> <%= l(:option_stem_some) %>
+ <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_ALL', @settings['dmsf_stemming_strategy'] == 'STEM_ALL', :disabled => xapian_disabled %> <%= l(:option_stem_all) %>
+
+ <%= l(:label_stemming_description) %>: +
+ STEM_NONE: <%=l(:note_do_not_stem) %>
+ STEM_SOME: <%=l(:note_stem_some) %>
+ STEM_ALL: <%=l(:note_stem_all) %>
+
+ <%= l(:note_stemming_applied) %>
+

diff --git a/db/migrate/06_dmsf_1_2_0.rb b/db/migrate/06_dmsf_1_2_0.rb index 7c1526b1..2f56385a 100644 --- a/db/migrate/06_dmsf_1_2_0.rb +++ b/db/migrate/06_dmsf_1_2_0.rb @@ -19,11 +19,11 @@ class Dmsf120 < ActiveRecord::Migration class DmsfFileRevision < ActiveRecord::Base - belongs_to :file, :class_name => "DmsfFile", :foreign_key => "dmsf_file_id" - belongs_to :source_revision, :class_name => "DmsfFileRevision", :foreign_key => "source_dmsf_file_revision_id" + belongs_to :file, :class_name => 'DmsfFile', :foreign_key => 'dmsf_file_id' + belongs_to :source_revision, :class_name => 'DmsfFileRevision', :foreign_key => 'source_dmsf_file_revision_id' belongs_to :user - belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "dmsf_folder_id" - belongs_to :deleted_by_user, :class_name => "User", :foreign_key => "deleted_by_user_id" + belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id' + belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id' belongs_to :project end diff --git a/db/migrate/07_dmsf_1_4_4.rb b/db/migrate/07_dmsf_1_4_4.rb index 4dc43b1f..cd98fe01 100644 --- a/db/migrate/07_dmsf_1_4_4.rb +++ b/db/migrate/07_dmsf_1_4_4.rb @@ -23,7 +23,7 @@ class Dmsf144 < ActiveRecord::Migration class DmsfFileLock < ActiveRecord::Base - belongs_to :file, :class_name => "DmsfFile", :foreign_key => "dmsf_file_id" + belongs_to :file, :class_name => 'DmsfFile', :foreign_key => 'dmsf_file_id' belongs_to :user end @@ -70,7 +70,7 @@ class Dmsf144 < ActiveRecord::Migration #We need to force our newly found - say "Applying default lock scope / type - Exclusive / Write" + say 'Applying default lock scope / type - Exclusive / Write' DmsfFileLock.update_all ['entity_type = ?, lock_type_cd = ?, lock_scope_cd = ?', 0, 0, 0] #These are not null-allowed columns @@ -107,9 +107,9 @@ class Dmsf144 < ActiveRecord::Migration say "Migration: #{existing} -> #{new_path} failed" end } - say "Action was successful" + say 'Action was successful' rescue Exception => e - say "Action was not successful" + say 'Action was not successful' puts e.message puts e.backtrace.inspect #See issue 86 #Nothing here, we just dont want a migration to break @@ -123,10 +123,10 @@ class Dmsf144 < ActiveRecord::Migration add_column :dmsf_file_locks, :locked, :boolean, :default => false, :null => false #Data cleanup - delete all expired locks, or any folder locks - say "Removing all expired and/or folder locks" + say 'Removing all expired and/or folder locks' DmsfFileLock.delete_all ['expires_at < ? OR entity_type = 1', Time.now] - say "Changing all records to be locked" + say 'Changing all records to be locked' DmsfFileLock.update_all ['locked = ?', true] rename_column :dmsf_file_locks, :entity_id, :dmsf_file_id @@ -139,7 +139,7 @@ class Dmsf144 < ActiveRecord::Migration #Not sure if this is the right place to do this, as its file manipulation, not database (stricly) begin - say "restoring old file-structure" + say 'restoring old file-structure' DmsfFileRevision.visible.each {|rev| next if rev.project.nil? project = rev.project.identifier.gsub(/[^\w\.\-]/,'_') diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index 203ff277..36bafe05 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -31,9 +31,9 @@ module RedmineDmsf unloadable alias_method_chain :copy, :dmsf - has_many :dmsf_files, :class_name => "DmsfFile", :foreign_key => "project_id", :conditions => { :dmsf_folder_id => nil } + has_many :dmsf_files, :class_name => 'DmsfFile', :foreign_key => 'project_id', :conditions => { :dmsf_folder_id => nil } #Fix: should only be root folders not, all folders - has_many :dmsf_folders, :class_name => "DmsfFolder", :foreign_key => "project_id", :conditions => {:dmsf_folder_id => nil}, :dependent => :destroy + has_many :dmsf_folders, :class_name => 'DmsfFolder', :foreign_key => 'project_id', :conditions => {:dmsf_folder_id => nil}, :dependent => :destroy has_many :dmsf_workflows, :dependent => :destroy end @@ -57,7 +57,7 @@ module RedmineDmsf project = project.is_a?(Project) ? project : Project.find(project) to_be_copied = %w(dmsf) - to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil? + to_be_copied = to_be_copied & options[:only].to_a if options[:only].present? if save to_be_copied.each do |name| diff --git a/lib/redmine_dmsf/test/integration_test.rb b/lib/redmine_dmsf/test/integration_test.rb index 4f414cd3..2095258e 100644 --- a/lib/redmine_dmsf/test/integration_test.rb +++ b/lib/redmine_dmsf/test/integration_test.rb @@ -22,12 +22,11 @@ module RedmineDmsf module Test class IntegrationTest < ActionController::IntegrationTest def self.fixtures(*table_names) - dir = File.join(File.dirname(__FILE__), "../../../test/fixtures" ) - modified_tables = table_names.reject{|x| !File.exist?(dir + "/" + x.to_s + ".yml") } + dir = File.join(File.dirname(__FILE__), '../../../test/fixtures') + modified_tables = table_names.reject{|x| !File.exist?("#{dir}/#{x}.yml") } ActiveRecord::Fixtures.create_fixtures(dir, modified_tables) unless modified_tables.empty? table_names -= modified_tables - super(table_names-modified_tables) - + super(table_names-modified_tables) end end end diff --git a/lib/redmine_dmsf/test/test_case.rb b/lib/redmine_dmsf/test/test_case.rb index b1bfafcf..64d0fdbb 100644 --- a/lib/redmine_dmsf/test/test_case.rb +++ b/lib/redmine_dmsf/test/test_case.rb @@ -26,9 +26,9 @@ module RedmineDmsf # Ultimately it allows for better integration without blowing redmine fixtures up, # and allowing us to suppliment redmine fixtures if we need to. def self.fixtures(*table_names) - dir = File.join( File.dirname(__FILE__), "../../../test/fixtures" ) + dir = File.join( File.dirname(__FILE__), '../../../test/fixtures') table_names.each{|x| - ActiveRecord::Fixtures.create_fixtures(dir, x) if File.exist?(dir + "/" + x.to_s + ".yml") + ActiveRecord::Fixtures.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml") } super(table_names) end diff --git a/lib/redmine_dmsf/test/unit_test.rb b/lib/redmine_dmsf/test/unit_test.rb index 2503a52a..011c3221 100644 --- a/lib/redmine_dmsf/test/unit_test.rb +++ b/lib/redmine_dmsf/test/unit_test.rb @@ -26,13 +26,13 @@ module RedmineDmsf # Ultimately it allows for better integration without blowing redmine fixtures up, # and allowing us to suppliment redmine fixtures if we need to. def self.fixtures(*table_names) - dir = File.expand_path( File.dirname(__FILE__) + "../../../../test/fixtures" ) + dir = File.expand_path( File.dirname(__FILE__) + '../../../../test/fixtures') table_names.each{|x,i| - ActiveRecord::Fixtures.create_fixtures(dir, x) if File.exist?(dir + "/" + x.to_s + ".yml") + ActiveRecord::Fixtures.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml") } super(table_names) end - + end end end diff --git a/lib/tasks/dmsf_alert_approvals.rake b/lib/tasks/dmsf_alert_approvals.rake index d0d8c0fb..cd4947fc 100644 --- a/lib/tasks/dmsf_alert_approvals.rake +++ b/lib/tasks/dmsf_alert_approvals.rake @@ -24,7 +24,7 @@ Available options: Example: rake redmine:dmsf_alert_approvals RAILS_ENV="production" END_DESC -require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment") +require File.expand_path(File.dirname(__FILE__) + '/../../../../config/environment') class DmsfAlertApprovals diff --git a/lib/tasks/dmsf_convert_documents.rake b/lib/tasks/dmsf_convert_documents.rake index e9191e3a..a5e122dc 100644 --- a/lib/tasks/dmsf_convert_documents.rake +++ b/lib/tasks/dmsf_convert_documents.rake @@ -34,36 +34,36 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environme class DmsfConvertDocuments def self.convert(options={}) - dry = options[:dry] ? options[:dry] == "true" : false - replace = options[:invalid] ? options[:invalid] == "replace" : false + dry = options[:dry] ? options[:dry] == 'true' : false + replace = options[:invalid] ? options[:invalid] == 'replace' : false projects = options[:project] ? [Project.find(options[:project])] : Project.find(:all) - projects.reject! {|project| project.module_enabled?("dmsf") } - projects.reject! {|project| !project.module_enabled?("documents") } + projects.reject! {|project| project.module_enabled?('dmsf') } + projects.reject! {|project| !project.module_enabled?('documents') } unless projects.nil? || projects.empty? projects.each do |project| - puts "Processing project: " + project.identifier + puts "Processing project: #{project.identifier}" - project.enabled_module_names = (project.enabled_module_names << "dmsf").uniq unless dry + project.enabled_module_names = (project.enabled_module_names << 'dmsf').uniq unless dry project.save! unless dry fail = false folders = [] project.documents.each do |document| - puts "Processing document: " + document.title + puts "Processing document: #{document.title}" folder = DmsfFolder.new folder.project = project - folder.user = (a = document.attachments.find(:first, :order => "created_on ASC")) ? a.author : User.find(:first) + folder.user = (a = document.attachments.find(:first, :order => 'created_on ASC')) ? a.author : User.find(:first) folder.title = document.title - folder.title.gsub!(/[\/\\\?":<>]/,"-") if replace + folder.title.gsub!(/[\/\\\?":<>]/, '-') if replace i = 1 - suffix = "" + suffix = '' while folders.index{|f| f.title == (folder.title + suffix)} i+=1 suffix = "_#{i}" @@ -73,16 +73,16 @@ class DmsfConvertDocuments folder.description = document.description if dry - puts "Dry check folder: " + folder.title + puts "Dry check folder: #{folder.title}" if folder.invalid? folder.errors.each {|e,msg| puts "#{e}: #{msg}"} end else begin folder.save! - puts "Created folder: " + folder.title + puts "Created folder: #{folder.title}" rescue Exception => e - puts "Creating folder: " + folder.title + " failed" + puts "Creating folder: #{folder.title} failed" puts e fail = true next @@ -91,8 +91,7 @@ class DmsfConvertDocuments folders << folder; - files = [] - failed_files = [] + files = [] document.attachments.each do |attachment| begin file = DmsfFile.new @@ -112,13 +111,13 @@ class DmsfConvertDocuments file.name = DmsfFileRevision.remove_extension(file.name) + suffix + File.extname(file.name) unless File.exist?(attachment.diskfile) - puts "Creating file: " + attachment.filename + " failed, attachment file doesn't exist" + puts "Creating file: #{attachment.filename} failed, attachment file doesn't exist" fail = true next end if dry - puts "Dry check file: " + file.name + puts "Dry check file: #{file.name}" if file.invalid? file.errors.each {|e,msg| puts "#{e}: #{msg}"} end @@ -138,14 +137,14 @@ class DmsfConvertDocuments revision.updated_at = attachment.created_on revision.major_version = 0 revision.minor_version = 1 - revision.comment = "Converted from documents" + revision.comment = 'Converted from documents' revision.mime_type = attachment.content_type revision.disk_filename = revision.new_storage_filename - attachment_file = File.open(attachment.diskfile, "rb") + attachment_file = File.open(attachment.diskfile, 'rb') unless dry - File.open(revision.disk_file, "wb") do |f| + File.open(revision.disk_file, 'wb') do |f| while (buffer = attachment_file.read(8192)) f.write(buffer) end @@ -156,7 +155,7 @@ class DmsfConvertDocuments attachment_file.close if dry - puts "Dry check revision: " + revision.title + puts "Dry check revision: #{revision.title}" if revision.invalid? revision.errors.each {|e,msg| puts "#{e}: #{msg}"} end @@ -168,9 +167,9 @@ class DmsfConvertDocuments attachment.destroy unless dry - puts "Created file: " + file.name unless dry + puts "Created file: #{file.name}" unless dry rescue Exception => e - puts "Creating file: " + attachment.filename + " failed" + puts "Creating file: #{attachment.filename} failed" puts e fail = true end @@ -179,7 +178,7 @@ class DmsfConvertDocuments document.destroy unless dry || fail end - project.enabled_module_names = project.enabled_module_names.reject {|mod| mod == "documents"} unless dry || fail + project.enabled_module_names = project.enabled_module_names.reject {|mod| mod == 'documents'} unless dry || fail project.save! unless dry end end