From a6cd8995135111d948f417f28b8b42a89acdfedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=92=D1=96=D0=BD=D0=BD?= =?UTF-8?q?=D0=B8=D1=87=D1=83=D0=BA?= Date: Wed, 24 Oct 2012 16:50:19 +0300 Subject: [PATCH 1/4] Updated temp downloadable zip file permissions to 0644 - useful when using XSendFile apache module for file downloads --- lib/dmsf_zip.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/dmsf_zip.rb b/lib/dmsf_zip.rb index d46cbcca..484c6bb3 100644 --- a/lib/dmsf_zip.rb +++ b/lib/dmsf_zip.rb @@ -21,25 +21,26 @@ require 'zip/zipfilesystem' require 'iconv' class DmsfZip - + attr_reader :files - + def initialize() @zip = Tempfile.new(["dmsf_zip",".zip"]) + @zip.chmod(0644) @zip_file = Zip::ZipOutputStream.new(@zip.path) @files = [] end - + def finish @zip_file.close unless @zip_file.nil? @zip.path unless @zip.nil? end - + def close @zip_file.close unless @zip_file.nil? @zip.close unless @zip.nil? end - + def add_file(file, root_path = nil) string_path = file.folder.nil? ? "" : file.folder.dmsf_path_str + "/" string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path @@ -50,7 +51,7 @@ class DmsfZip rescue end @zip_file.put_next_entry(string_path) - File.open(file.last_revision.disk_file, "rb") do |f| + File.open(file.last_revision.disk_file, "rb") do |f| buffer = "" while (buffer = f.read(8192)) @zip_file.write(buffer) @@ -58,7 +59,7 @@ class DmsfZip end @files << file end - + def add_folder(folder, root_path = nil) string_path = folder.dmsf_path_str + "/" string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path @@ -71,5 +72,5 @@ class DmsfZip folder.subfolders.visible.each { |subfolder| self.add_folder(subfolder, root_path) } folder.files.visible.each { |file| self.add_file(file, root_path) } end - -end \ No newline at end of file + +end From 9260bb2a7afbefd383c32800aa8c46d12c76846f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=92=D1=96=D0=BD=D0=BD?= =?UTF-8?q?=D0=B8=D1=87=D1=83=D0=BA?= Date: Wed, 24 Oct 2012 16:51:59 +0300 Subject: [PATCH 2/4] Line breaks converted to unix for file lib/dmsf_zip.rb --- lib/dmsf_zip.rb | 152 ++++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/lib/dmsf_zip.rb b/lib/dmsf_zip.rb index 484c6bb3..fee69e17 100644 --- a/lib/dmsf_zip.rb +++ b/lib/dmsf_zip.rb @@ -1,76 +1,76 @@ -# Redmine plugin for Document Management System "Features" -# -# Copyright (C) 2011 Vít Jonáš -# -# 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. - -require 'zip/zip' -require 'zip/zipfilesystem' -require 'iconv' - -class DmsfZip - - attr_reader :files - - def initialize() - @zip = Tempfile.new(["dmsf_zip",".zip"]) - @zip.chmod(0644) - @zip_file = Zip::ZipOutputStream.new(@zip.path) - @files = [] - end - - def finish - @zip_file.close unless @zip_file.nil? - @zip.path unless @zip.nil? - end - - def close - @zip_file.close unless @zip_file.nil? - @zip.close unless @zip.nil? - end - - def add_file(file, root_path = nil) - string_path = file.folder.nil? ? "" : file.folder.dmsf_path_str + "/" - string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path - string_path += file.name - #TODO: somewhat ugly conversion problems handling bellow - begin - string_path = Iconv.conv(Setting.plugin_redmine_dmsf["dmsf_zip_encoding"], "utf-8", string_path) - rescue - end - @zip_file.put_next_entry(string_path) - File.open(file.last_revision.disk_file, "rb") do |f| - buffer = "" - while (buffer = f.read(8192)) - @zip_file.write(buffer) - end - end - @files << file - end - - def add_folder(folder, root_path = nil) - string_path = folder.dmsf_path_str + "/" - string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path - #TODO: somewhat ugly conversion problems handling bellow - begin - string_path = Iconv.conv(Setting.plugin_redmine_dmsf["dmsf_zip_encoding"], "utf-8", string_path) - rescue - end - @zip_file.put_next_entry(string_path) - folder.subfolders.visible.each { |subfolder| self.add_folder(subfolder, root_path) } - folder.files.visible.each { |file| self.add_file(file, root_path) } - end - -end +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011 Vít Jonáš +# +# 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. + +require 'zip/zip' +require 'zip/zipfilesystem' +require 'iconv' + +class DmsfZip + + attr_reader :files + + def initialize() + @zip = Tempfile.new(["dmsf_zip",".zip"]) + @zip.chmod(0644) + @zip_file = Zip::ZipOutputStream.new(@zip.path) + @files = [] + end + + def finish + @zip_file.close unless @zip_file.nil? + @zip.path unless @zip.nil? + end + + def close + @zip_file.close unless @zip_file.nil? + @zip.close unless @zip.nil? + end + + def add_file(file, root_path = nil) + string_path = file.folder.nil? ? "" : file.folder.dmsf_path_str + "/" + string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path + string_path += file.name + #TODO: somewhat ugly conversion problems handling bellow + begin + string_path = Iconv.conv(Setting.plugin_redmine_dmsf["dmsf_zip_encoding"], "utf-8", string_path) + rescue + end + @zip_file.put_next_entry(string_path) + File.open(file.last_revision.disk_file, "rb") do |f| + buffer = "" + while (buffer = f.read(8192)) + @zip_file.write(buffer) + end + end + @files << file + end + + def add_folder(folder, root_path = nil) + string_path = folder.dmsf_path_str + "/" + string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path + #TODO: somewhat ugly conversion problems handling bellow + begin + string_path = Iconv.conv(Setting.plugin_redmine_dmsf["dmsf_zip_encoding"], "utf-8", string_path) + rescue + end + @zip_file.put_next_entry(string_path) + folder.subfolders.visible.each { |subfolder| self.add_folder(subfolder, root_path) } + folder.files.visible.each { |file| self.add_file(file, root_path) } + end + +end From f0f61e859b8ce31562b57d9c5ebd660db65bb55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=92=D1=96=D0=BD=D0=BD?= =?UTF-8?q?=D0=B8=D1=87=D1=83=D0=BA?= Date: Wed, 24 Oct 2012 17:38:34 +0300 Subject: [PATCH 3/4] Created hack, when entries were selected and downloaded (by pressing download button) and after that downloading of other selected files couldn't be achieved without page reload (simply pressing download button does nothing). --- app/views/dmsf/show.html.erb | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index e59b50c4..cb423fd8 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -43,7 +43,7 @@ <%= render "custom_fields", :object => @folder %> -<%= form_tag({:action => :entries_operation, :id => @project, :folder_id => @folder}, :method => :post, +<%= form_tag({:action => :entries_operation, :id => @project, :folder_id => @folder}, :method => :post, :class => "dmfs_entries", :id => "entries_form") do %> <%= hidden_field_tag("action") %>
@@ -52,7 +52,7 @@ <% if User.current.allowed_to?(:file_manipulation, @project) && (!@folder.nil? && !@folder.locked_for_user?) %> <% end %> -
+ @@ -101,7 +101,7 @@ :title => l(:title_notifications_active_deactivate)) %> <% else %> <%= link_to_function(image_tag("notifynot.png", :plugin => :redmine_dmsf), - "manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')", + "manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')", :title => l(:title_notifications_not_active_activate)) %> <% end %> @@ -109,7 +109,7 @@
<% if User.current.allowed_to?(:folder_manipulation, @project) %>
- <%= link_to(image_tag("edit.png", :class =>"detail_icon"), + <%= link_to(image_tag("edit.png", :class =>"detail_icon"), {:action => "edit", :id => @project, :folder_id => subfolder }, :title => l(:link_edit, :title => h(subfolder.title))) unless subfolder.locked_for_user? %>
@@ -119,7 +119,7 @@ <% if subfolder.locked? %> <% if subfolder.unlockable? %> <%= link_to_function(image_tag("unlock.png", :plugin => :redmine_dmsf), - "manipulation_link('#{url_for(:controller => "dmsf", :action => 'unlock', + "manipulation_link('#{url_for(:controller => "dmsf", :action => 'unlock', :id => @project, :folder_id => subfolder)}')", :title => l(:title_unlock_file))%> <% else %> @@ -127,14 +127,14 @@ <% end %> <% else %> <%= link_to_function(image_tag("lock.png", :plugin => :redmine_dmsf), - "manipulation_link('#{url_for(:controller => "dmsf", :action => 'lock', + "manipulation_link('#{url_for(:controller => "dmsf", :action => 'lock', :id => @project, :folder_id => subfolder)}')", :title => l(:title_lock_file)) %> <% end %>   <% end %> <%= 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)}')", + "confirmation_link('#{url_for(:action => 'delete', :id => @project, :folder_id => @folder, :delete_folder_id => subfolder)}')", :title => l(:title_delete)) unless (subfolder.locked_for_user?)%>
@@ -161,7 +161,7 @@
<%= format_time(file.last_revision.updated_at) %> <% 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.lock.reverse[0].user }, :title => l(:title_locked_by_user, :user => file.lock.reverse[0].user.to_s)) %> <% elsif file.locked? %> @@ -194,7 +194,7 @@ <% 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))) %>
@@ -212,7 +212,7 @@ <%= 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 %>   <% end %> <% if User.current.allowed_to?(:file_manipulation, @project) && !file.locked_for_user? %> @@ -240,7 +240,7 @@ jQuery("#entries_form").submit(); } }) - + jQuery("#check_all_entries").click(function(event) { var $this = jQuery(this); if($this.prop("checked")) { @@ -248,7 +248,7 @@ } else { jQuery("input[type=checkbox]", jQuery("#browser > tbody")).prop("checked", false); } - }) + }) <% @@ -261,7 +261,7 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && ! <%= stylesheet_link_tag "plupload/jquery.ui.plupload.css", :plugin => "redmine_dmsf" %> <%= stylesheet_link_tag "jquery.dataTables/jquery-ui.dataTables.css", :plugin => "redmine_dmsf" %> <%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %> - + <%= javascript_include_tag "jquery-1.6.1.min.js", :plugin => "redmine_dmsf" %> <%= javascript_include_tag "jquery-ui-1.8.13.min.js", :plugin => "redmine_dmsf" %> <%= javascript_include_tag "jquery.dataTables/jquery.dataTables.min.js", :plugin => "redmine_dmsf" %> @@ -289,7 +289,7 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && ! return "<%= l(:label_number_of_folders)%>: <%= @subfolders.length %>, <%= l(:label_number_of_documents)%>: <%= @files.length %>"; } }); - + jQuery("[data-downloadurl]").each(function() { var url = this.getAttribute("data-downloadurl"); if (this.addEventListener) { @@ -300,13 +300,17 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && ! },false); } }); + + jQuery("#entries_form").submit(function () { + jQuery(this).removeAttr('data-submitted'); + }); }); - + function manipulation_link(action) { jQuery("#entries_form").attr("action", action); jQuery("#entries_form").submit(); }; - + function confirmation_link(action) { if(!window.confirm("<%= l(:question_do_you_really_want_to_delete_this_entry) %>")) return; jQuery("#entries_form").attr("action", action); @@ -315,6 +319,6 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && ! <% end %> -<%= render(:partial => "multi_upload") if (User.current.allowed_to?(:file_manipulation, @project) && +<%= render(:partial => "multi_upload") if (User.current.allowed_to?(:file_manipulation, @project) && ( @folder.nil? || (!@folder.nil? &&!@folder.locked_for_user?) ) ) %>
From 41bf9af83c505a44c45d314f9a52397768be9396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=92=D1=96=D0=BD=D0=BD?= =?UTF-8?q?=D0=B8=D1=87=D1=83=D0=BA?= Date: Wed, 24 Oct 2012 18:03:42 +0300 Subject: [PATCH 4/4] Fix for Rails 3.1+ (Redmine 2.x), which does not contain prototype.js library anymore --- app/views/dmsf_files_copy/new.html.erb | 20 ++++++++++---------- app/views/dmsf_folders_copy/new.html.erb | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/views/dmsf_files_copy/new.html.erb b/app/views/dmsf_files_copy/new.html.erb index b37865bc..a51d6dc4 100644 --- a/app/views/dmsf_files_copy/new.html.erb +++ b/app/views/dmsf_files_copy/new.html.erb @@ -7,7 +7,7 @@

<%= render(:partial => "/dmsf/path", :locals => {:path => path}) %> / -<%= link_to(h(@file.title), {:controller => "dmsf_files", :action => "show", :id=> @file}) %> +<%= 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 %>

@@ -17,21 +17,17 @@

<%= select_tag("target_project_id", - project_tree_options_for_select(DmsfFile.allowed_target_projects_on_copy, :selected => @target_project), - :onchange => remote_function(:url => { :action => 'new' }, - :method => :get, - :update => 'content', - :with => "Form.serialize('copyForm')")) %> + 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), + <%= 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) %> @@ -44,6 +40,10 @@ jQuery("#copyForm").attr("action", "<%= url_for(:action => 'move', :id => @file) %>"); jQuery("#copyForm").submit(); }); + + jQuery("#target_project_id").change(function () { + jQuery("#content").load("<%= url_for(:action => 'new') %>", jQuery("#copyForm").serialize()); + }); <% content_for :header_tags do %> diff --git a/app/views/dmsf_folders_copy/new.html.erb b/app/views/dmsf_folders_copy/new.html.erb index 5f721e71..bda0ef7a 100644 --- a/app/views/dmsf_folders_copy/new.html.erb +++ b/app/views/dmsf_folders_copy/new.html.erb @@ -11,24 +11,26 @@

<%= select_tag("target_project_id", - project_tree_options_for_select(DmsfFolder.allowed_target_projects_on_copy, :selected => @target_project), - :onchange => remote_function(:url => { :action => 'new' }, - :method => :get, - :update => 'content', - :with => "Form.serialize('copyForm')")) %> + 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), + <%= 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 %> <% 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" %>