* done Issue 167: Feature Patch: Maximum filesize for email downloads

git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@267 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
vit.jonas@gmail.com 2011-10-29 14:53:10 +00:00
parent 26c76ae69e
commit fe8e362b2c
11 changed files with 45 additions and 0 deletions

View File

@ -59,6 +59,9 @@ class DmsfController < ApplicationController
rescue ZipMaxFilesError
flash[:error] = l(:error_max_files_exceeded, :number => Setting.plugin_redmine_dmsf["dmsf_max_file_download"].to_i.to_s)
redirect_to({:controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder})
rescue EmailMaxFileSize
flash[:error] = l(:error_max_email_filesize_exceeded, :number => Setting.plugin_redmine_dmsf["dmsf_max_email_filesize"].to_s)
redirect_to({:controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder})
rescue DmsfAccessError
render_403
end
@ -80,6 +83,9 @@ class DmsfController < ApplicationController
class ZipMaxFilesError < StandardError
end
class EmailMaxFileSize < StandardError
end
def delete_entries
selected_folders = params[:subfolders]
selected_files = params[:files]
@ -237,6 +243,11 @@ class DmsfController < ApplicationController
f.write(buffer)
end
end
max_filesize = Setting.plugin_redmine_dmsf["dmsf_max_email_filesize"].to_f
if max_filesize > 0 && File.size(ziped_content) > max_filesize * 1048576
raise EmailMaxFileSize
end
zip.files.each do |f|
log_activity(f,"emailing zip")

View File

@ -14,6 +14,14 @@
<%= l(:note_maximum_number_of_files_downloaded) %>
</p>
<p>
<%=content_tag(:label, l(:label_maximum_email_filesize) + ":") %>
<%=text_field_tag "settings[dmsf_max_email_filesize]", @settings["dmsf_max_email_filesize"], :size=>10 %><br/>
(<%=l(:label_default)%>: 0)
<br/>
<%= l(:note_maximum_email_filesize) %>
</p>
<p>
<%=content_tag(:label, l(:label_file_storage_directory) + ":") %>
<%

View File

@ -182,4 +182,7 @@ cs:
:title_copy: "Kopírovat"
:error_folder_cannot_be_copied: "Složka nemůže být zkopírována"
:notice_folder_copied: "Složka zkopírována"
:error_max_email_filesize_exceeded: "Přesáhli jste maximální velikost souboru, který lze poslat emailem. (%{number} MB)"
:note_maximum_email_filesize: "Omezí se maximální velikost souboru, který může být poslán emailem. 0 znamená neomezený. Číslo je v MB."
:label_maximum_email_filesize: "Maximální velikost souboru emailu"

View File

@ -183,4 +183,7 @@ de:
:title_copy: "Copy"
:error_folder_cannot_be_copied: "Folder can't be copied"
:notice_folder_copied: "Folder copied"
:error_max_email_filesize_exceeded: "You've exceeded the maximum filesize for sending via email. (%{number} MB)"
:note_maximum_email_filesize: "Limits maximum filesize that can be sent via email. 0 means unlimited. Number is in MB."
:label_maximum_email_filesize: "Maximum email attachment size"

View File

@ -178,4 +178,7 @@ en-GB:
:title_copy: "Copy"
:error_folder_cannot_be_copied: "Folder can't be copied"
:notice_folder_copied: "Folder copied"
:error_max_email_filesize_exceeded: "You've exceeded the maximum filesize for sending via email. (%{number} MB)"
:note_maximum_email_filesize: "Limits maximum filesize that can be sent via email. 0 means unlimited. Number is in MB."
:label_maximum_email_filesize: "Maximum email attachment size"

View File

@ -178,4 +178,7 @@ en-GB:
:title_copy: "Copy"
:error_folder_cannot_be_copied: "Folder can't be copied"
:notice_folder_copied: "Folder copied"
:error_max_email_filesize_exceeded: "You've exceeded the maximum filesize for sending via email. (%{number} MB)"
:note_maximum_email_filesize: "Limits maximum filesize that can be sent via email. 0 means unlimited. Number is in MB."
:label_maximum_email_filesize: "Maximum email attachment size"

View File

@ -182,4 +182,8 @@ en:
:title_copy: "Copy"
:error_folder_cannot_be_copied: "Folder can't be copied"
:notice_folder_copied: "Folder copied"
:error_max_email_filesize_exceeded: "You've exceeded the maximum filesize for sending via email. (%{number} MB)"
:note_maximum_email_filesize: "Limits maximum filesize that can be sent via email. 0 means unlimited. Number is in MB."
:label_maximum_email_filesize: "Maximum email attachment size"

View File

@ -180,4 +180,7 @@ es:
:title_copy: "Copy"
:error_folder_cannot_be_copied: "Folder can't be copied"
:notice_folder_copied: "Folder copied"
:error_max_email_filesize_exceeded: "You've exceeded the maximum filesize for sending via email. (%{number} MB)"
:note_maximum_email_filesize: "Limits maximum filesize that can be sent via email. 0 means unlimited. Number is in MB."
:label_maximum_email_filesize: "Maximum email attachment size"

View File

@ -178,4 +178,7 @@ fr:
:title_copy: "Copy"
:error_folder_cannot_be_copied: "Folder can't be copied"
:notice_folder_copied: "Folder copied"
:error_max_email_filesize_exceeded: "You've exceeded the maximum filesize for sending via email. (%{number} MB)"
:note_maximum_email_filesize: "Limits maximum filesize that can be sent via email. 0 means unlimited. Number is in MB."
:label_maximum_email_filesize: "Maximum email attachment size"

View File

@ -184,4 +184,7 @@ ru:
:title_copy: "Copy"
:error_folder_cannot_be_copied: "Folder can't be copied"
:notice_folder_copied: "Folder copied"
:error_max_email_filesize_exceeded: "You've exceeded the maximum filesize for sending via email. (%{number} MB)"
:note_maximum_email_filesize: "Limits maximum filesize that can be sent via email. 0 means unlimited. Number is in MB."
:label_maximum_email_filesize: "Maximum email attachment size"

View File

@ -39,6 +39,7 @@ Redmine::Plugin.register :redmine_dmsf do
:default => {
"dmsf_max_file_upload" => "0",
"dmsf_max_file_download" => "0",
"dmsf_max_email_filesize" => "0",
"dmsf_storage_directory" => "#{RAILS_ROOT}/files/dmsf",
"dmsf_zip_encoding" => "utf-8",
"dmsf_index_database" => "#{RAILS_ROOT}/files/dmsf_index",