diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 07dfe002..b0538679 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -24,10 +24,10 @@ class DmsfController < ApplicationController before_filter :find_folder, :except => [:new, :create, :edit_root, :save_root] before_filter :find_parent, :only => [:new, :create] - verify :method => :post, :only => [:delete_entries, :create, :save, :delete, :save_root, :notify_activate, :notify_deactivate], - :render => { :nothing => true, :status => :method_not_allowed } +# verify :method => :post, :only => [:delete_entries, :create, :save, :delete, :save_root, :notify_activate, :notify_deactivate], +# :render => { :nothing => true, :status => :method_not_allowed } - helper :all + helper :all def show if @folder.nil? diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index 9c774ff3..c7a8e1ab 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -25,11 +25,11 @@ class DmsfFilesController < ApplicationController before_filter :find_revision, :only => [:delete_revision] before_filter :authorize - verify :method => :post, :only => [:create_revision, :delete_revision, :delete, :lock, :unlock, :notify_activate, :notify_deactivate], - :render => { :nothing => true, :status => :method_not_allowed } +# verify :method => :post, :only => [:create_revision, :delete_revision, :delete, :lock, :unlock, :notify_activate, :notify_deactivate], +# :render => { :nothing => true, :status => :method_not_allowed } + + helper :all - helper :all - def show # download is put here to provide more clear and usable links if params.has_key?(:download) diff --git a/app/controllers/dmsf_files_copy_controller.rb b/app/controllers/dmsf_files_copy_controller.rb index 806075ff..44dca170 100644 --- a/app/controllers/dmsf_files_copy_controller.rb +++ b/app/controllers/dmsf_files_copy_controller.rb @@ -24,10 +24,10 @@ class DmsfFilesCopyController < ApplicationController before_filter :find_file before_filter :authorize - verify :method => :post, :only => [:create, :move], :render => { :nothing => true, :status => :method_not_allowed } +# verify :method => :post, :only => [:create, :move], :render => { :nothing => true, :status => :method_not_allowed } + + helper :all - helper :all - def new @target_project = DmsfFile.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?(:file_manipulation, @project) diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index a6ef0c61..b48d285e 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -25,8 +25,8 @@ class DmsfUploadController < ApplicationController before_filter :authorize before_filter :find_folder, :except => [:upload_file] - verify :method => :post, :only => [:upload_files, :upload_file, :commit_files], - :render => { :nothing => true, :status => :method_not_allowed } +# verify :method => :post, :only => [:upload_files, :upload_file, :commit_files], +# :render => { :nothing => true, :status => :method_not_allowed } helper :all diff --git a/app/helpers/dmsf_helper.rb b/app/helpers/dmsf_helper.rb index 5fd81552..583703bf 100644 --- a/app/helpers/dmsf_helper.rb +++ b/app/helpers/dmsf_helper.rb @@ -59,5 +59,9 @@ module DmsfHelper return Redmine::MimeType.css_class_of(filename) end end + + def plugin_asset_path(plugin, asset_type, source) + return "/plugin_assets/#{plugin}/#{asset_type}/#{source}" + end end diff --git a/app/views/dmsf/_multi_upload.html.erb b/app/views/dmsf/_multi_upload.html.erb index 06b1135e..0daf2212 100644 --- a/app/views/dmsf/_multi_upload.html.erb +++ b/app/views/dmsf/_multi_upload.html.erb @@ -1,5 +1,5 @@
- <% form_tag({:controller => "dmsf_upload", :action => "upload_files", :id => @project, :folder_id => @folder}, + <%= form_tag({:controller => "dmsf_upload", :action => "upload_files", :id => @project}, :id => "uploadform", :method=>:post, :multipart => true) do %> <% if Setting.attachment_max_size.to_i >= 102400 %>
@@ -79,7 +79,7 @@ uploader = jQuery("div",uploader); uploader.plupload({ runtimes : 'html5,flash,html4', - url : '<%= url_for({:controller => "dmsf_upload", :action => "upload_file", :id => @project, :folder_id => @folder}) %>', + url : '<%= url_for({:controller => "dmsf_upload", :action => "upload_file", :id => @project}) %>', max_file_size : "100mb", max_file_count: '<%= Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i if Setting.plugin_redmine_dmsf["dmsf_max_file_upload"].to_i > 0 %>', multipart: true, @@ -89,7 +89,7 @@ rename: true, // Flash settings - flash_swf_url : '<%= Engines::RailsExtensions::AssetHelpers.plugin_asset_path("redmine_dmsf", "javascripts", "plupload/plupload.flash.swf") %>' + flash_swf_url : '<%= plugin_asset_path(:redmine_dmsf, "javascripts", "plupload/plupload.flash.swf") %>' }); jQuery(".plupload_scroll",uploader).resizable({ handles: "s" diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index aa8bae89..a781bcdf 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -3,8 +3,9 @@
<% if User.current.allowed_to?(:folder_manipulation, @project) %> <% if @folder.nil? %> - <%= link_to("", {:action => "edit_root", :id => @project}, - :title => l(:link_edit, :title => l(:link_documents)), :class => "icon icon-edit") %>   + <%= link_to("", :method => :edit_root, :title => l(:link_edit, :title => l(:link_documents)), :class => "icon icon-edit") %>   +   <% else @folder.nil? %> <%= link_to("", {:action => "edit", :id => @project, :folder_id => @folder }, :title => l(:link_edit, :title => h(@folder.title)), :class => "icon icon-edit") %>   @@ -25,10 +26,8 @@
<%= render "custom_fields", :object => @folder %>
-<% -form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder}, :method => :post, - :class => "dmfs_entries", :id => "entries_form") do -%> +<%= form_tag({:method => :entries_operation, :id => @project, :folder_id => @folder}, :method => :post, + :class => "dmfs_entries", :id => "entries_form") do %> <%= hidden_field_tag("action") %>
<%= submit_tag(l(:submit_download), :title => l(:title_download_checked), :name => "download_entries") %> @@ -72,11 +71,11 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder <% if User.current.allowed_to?(:file_approval, @project) %>
<% if subfolder.notification %> - <%= link_to_function(image_tag("notify.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("notify.png", :plugin => :redmine_dmsf), "manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @project, :folder_id => subfolder)}')", :title => l(:title_notifications_active_deactivate)) %> <% else %> - <%= link_to_function(image_tag("notifynot.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("notifynot.png", :plugin => :redmine_dmsf), "manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')", :title => l(:title_notifications_not_active_activate)) %> <% end %> @@ -91,7 +90,7 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<% end %>
- <%= link_to_function(image_tag("delete.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("delete.png", :plugin => :redmine_dmsf), "confirmation_link('#{url_for(:action => 'delete', :id => @project, :folder_id => @folder, :delete_folder_id => subfolder)}')", :title => l(:title_delete))%>
@@ -119,12 +118,12 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder <%= file.last_revision.updated_at.strftime("%Y-%m-%d %H:%M") %> <% if file.locked_for_user? %> - <%= link_to(image_tag("locked.png", :plugin => "redmine_dmsf"), + <%= link_to(image_tag("locked.png", :plugin => :redmine_dmsf), {:controller => "users", :action => "show", :id => file.locks[0].user }, :title => l(:title_locked_by_user, :user => file.locks[0].user.to_s)) %> <% else if file.locked? %> - <%= image_tag("lockedbycurrent.png", :title => l(:title_locked_by_you), :plugin => "redmine_dmsf") %> + <%= image_tag("lockedbycurrent.png", :title => l(:title_locked_by_you), :plugin => :redmine_dmsf) %> <% end %> <% end %> @@ -132,9 +131,9 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder <%= file.last_revision.version %> <% case file.last_revision.workflow when 1 then %><%= image_tag("waitingforapproval.png", :title => l(:title_waiting_for_approval), - :plugin => "redmine_dmsf") %> + :plugin => :redmine_dmsf) %> <% when 2 then %><%= image_tag("approved.png", :title => l(:title_approved), - :plugin => "redmine_dmsf") %> + :plugin => :redmine_dmsf) %> <% end %> <%= h(file.last_revision.user) %> @@ -142,11 +141,11 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder <% if User.current.allowed_to?(:file_approval, @project) %>
<% if file.notification %> - <%= link_to_function(image_tag("notify.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("notify.png", :plugin => :redmine_dmsf), "manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'notify_deactivate', :id => file)}')", :title => l(:title_notifications_active_deactivate)) %> <% else %> - <%= link_to_function(image_tag("notifynot.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("notifynot.png", :plugin => :redmine_dmsf), "manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'notify_activate', :id => file)}')", :title => l(:title_notifications_not_active_activate)) %> <% end %> @@ -154,25 +153,25 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder <% end %>
- <%= link_to(image_tag("filedetails.png", :plugin => "redmine_dmsf", :class =>"detail_icon"), + <%= link_to(image_tag("filedetails.png", :plugin => :redmine_dmsf, :class =>"detail_icon"), {:controller => "dmsf_files", :action => :show, :id => file }, :title => l(:link_details, :title =>h(file.last_revision.title))) %>
<% unless file.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, @project)%> <% if file.locked? %> - <%= link_to_function(image_tag("unlock.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("unlock.png", :plugin => :redmine_dmsf), "manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'unlock', :id => file)}')", :title => l(:title_unlock_file)) %> <% else %> - <%= link_to_function(image_tag("lock.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("lock.png", :plugin => :redmine_dmsf), "manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'lock', :id => file)}')", :title => l(:title_lock_file)) %> <% end %>   <% end %> <% if User.current.allowed_to?(:file_manipulation, @project) && !file.locked_for_user? %> - <%= link_to_function(image_tag("delete.png", :plugin => "redmine_dmsf"), + <%= link_to_function(image_tag("delete.png", :plugin => :redmine_dmsf), "confirmation_link('#{url_for(:controller => "dmsf_files", :action => 'delete', :id => file)}')", :title => l(:title_delete)) %> <% end %> @@ -192,7 +191,7 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder @@ -194,4 +194,4 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && ! jQuery("#manipulation_form").submit(); }; -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/dmsf_upload/upload_files.html.erb b/app/views/dmsf_upload/upload_files.html.erb index 8f2d8248..38a1532b 100644 --- a/app/views/dmsf_upload/upload_files.html.erb +++ b/app/views/dmsf_upload/upload_files.html.erb @@ -13,11 +13,9 @@

<%=l(:heading_uploaded_files)%>

-<% -i = 1 -form_tag({:action => "commit_files", :id => @project, :folder_id => @folder}, - :method=>:post) do -%> +<% 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}) %> @@ -38,4 +36,4 @@ form_tag({:action => "commit_files", :id => @project, :folder_id => @folder}, jQuery(document).ready(function() { }); -<% end %> \ No newline at end of file +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 9afd3f5c..ba5f5f39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,7 +16,36 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -ActionController::Routing::Routes.draw do |map| - map.resources :dmsf - map.resources :dmsf_files +#ActionController::Routing::Routes.draw do |map| +RedmineApp::Application.routes.draw do +# map.resources :dmsf +# map.resources :dmsf_files + resources :dmsf +# resources :dmsf_files + + post '/dmsf/:id/upload/files', :controller => 'dmsf_upload', :action => 'upload_files' + post '/dmsf/:id/upload/file', :controller => 'dmsf_upload', :action => 'upload_file' + post '/dmsf/:id/upload/commit', :controller => 'dmsf_upload', :action => 'commit_files' + + #/dmsf/files - dmsf_files controller + post '/dmsf/files/:id/notify/activate', :controller => 'dmsf_files', :action => 'notify_activate' + post '/dmsf/files/:id/notify/deactivate', :controller => 'dmsf_files', :action => 'notify_deactivate' + post '/dmsf/files/:id/lock', :controller => 'dmsf_files', :action => 'lock' + post '/dmsf/files/:id/unlock', :controller => 'dmsf_files', :action => 'unlock' + post '/dmsf/files/:id/delete', :controller => 'dmsf_files', :action => 'delete' + post '/dmsf/files/:id/revision/create', :controller => 'dmsf_files', :action => 'create_revision' + post '/dmsf/files/revision/:id/delete', :controller => 'dmsf_files', :action => 'delete_revision' + + get '/dmsf/files/:id/download', :controller => 'dmsf_files', :action => 'show', :download => '' + get '/dmsf/files/:id/revision/:download/download', :controller => 'dmsf_files', :action => 'show', :download => /\d*/ + get '/dmsf/files/:id', :controller => 'dmsf_files', :action => 'show' +# post '/dmsf/files/:id/revision/delete' + + + # + # files_copy controller + ## +##### POST :create, :move + get '/dmsf/files/:id/copy', :controller => 'dmsf_files_copy', :action => 'new' + end diff --git a/init.rb b/init.rb index 8fd997d0..89723de1 100644 --- a/init.rb +++ b/init.rb @@ -17,18 +17,21 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'redmine' -require 'dispatcher' +#require 'dispatcher' -Dispatcher.to_prepare :redmine_dmsf do +#Dispatcher.to_prepare :redmine_dmsf do +Rails.configuration.to_prepare do unless ProjectsHelper.included_modules.include?(ProjectTabsExtended) ProjectsHelper.send(:include, ProjectTabsExtended) - end + end unless CustomFieldsHelper.included_modules.include?(CustomFieldsHelper) CustomFieldsHelper.send(:include, RedmineDmsf::Patches::CustomFieldsHelper) end Project.send(:include, RedmineDmsf::Patches::ProjectPatch) + STDOUT.puts "PATCHES SENT\n" + STDOUT.flush end Redmine::Plugin.register :redmine_dmsf do @@ -46,9 +49,9 @@ Redmine::Plugin.register :redmine_dmsf do "dmsf_max_file_upload" => "0", "dmsf_max_file_download" => "0", "dmsf_max_email_filesize" => "0", - "dmsf_storage_directory" => "#{RAILS_ROOT}/files/dmsf", + "dmsf_storage_directory" => Rails.root.join('files/dmsf').to_s, #{RAILS_ROOT}/files/dmsf", "dmsf_zip_encoding" => "utf-8", - "dmsf_index_database" => "#{RAILS_ROOT}/files/dmsf_index", + "dmsf_index_database" => Rails.root.join("files/dmsf_index").to_s, "dmsf_stemming_lang" => "english", "dmsf_stemming_strategy" => "STEM_NONE" } diff --git a/lib/redmine_dmsf/patches/acts_as_customizable.rb b/lib/redmine_dmsf/patches/acts_as_customizable.rb index fbc859dd..88a24625 100644 --- a/lib/redmine_dmsf/patches/acts_as_customizable.rb +++ b/lib/redmine_dmsf/patches/acts_as_customizable.rb @@ -1,16 +1,16 @@ module Redmine - module Acts - module Customizable - module InstanceMethods - def available_custom_fields - cf_classname = self.class.name == 'DmsfFolder' ? 'DmsfFileRevision' : self.class.name - CustomField.find(:all, :conditions => "type = '#{cf_classname}CustomField'", :order => 'position') - end + module Acts + module Customizable + module InstanceMethods + def available_custom_fields + cf_classname = self.class.name == 'DmsfFolder' ? 'DmsfFileRevision' : self.class.name + CustomField.find(:all, :conditions => "type = '#{cf_classname}CustomField'", :order => 'position') + end - def show_custom_field_values - custom_field_values.delete_if { |x| (!x.id && x.id.blank?) || x.value.blank? } - end - end - end - end -end \ No newline at end of file + def show_custom_field_values + custom_field_values.delete_if { |x| (!x.id && x.id.blank?) || x.value.blank? } + end + end + end + end +end diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index d200430d..59114331 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -1,9 +1,21 @@ +require_dependency 'project' module RedmineDmsf - module Patches - module ProjectPatch - def all_dmsf_custom_fields - @all_dmsf_custom_fields ||= (DmsfFileRevisionCustomField.for_all + dmsf_file_revision_custom_fields).uniq.sort - end - end - end -end \ No newline at end of file + module Patches + module ProjectPatch + + def self.included(base) # :nodoc: + base.send(:include, InstanceMethods) + base.extend(ClassMethods) + end + + module ClassMethods + end + + module InstanceMethods + def all_dmsf_custom_fields + @all_dmsf_custom_fields ||= (DmsfFileRevisionCustomField.for_all).uniq.sort # + dmsf_file_revision_custom_fields).uniq.sort + end + end + end + end +end