diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 1b01ed61..c22528e3 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -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") diff --git a/app/views/settings/_dmsf_settings.erb b/app/views/settings/_dmsf_settings.erb index c21aa603..58c4dccc 100644 --- a/app/views/settings/_dmsf_settings.erb +++ b/app/views/settings/_dmsf_settings.erb @@ -14,6 +14,14 @@ <%= 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) + ":") %> <% diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 0daa902c..506607e7 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -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" \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index 10c83e0d..d4d16cd8 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -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" \ No newline at end of file diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 65534338..b25a8320 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -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" \ No newline at end of file diff --git a/config/locales/en-IS.yml b/config/locales/en-IS.yml index 65534338..b25a8320 100644 --- a/config/locales/en-IS.yml +++ b/config/locales/en-IS.yml @@ -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" \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 429a93f0..639e96b6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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" \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index 2bf8c994..53b767fb 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -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" \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index eefb9cd7..9eb0cce3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -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" \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 03906504..3b6273e7 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -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" \ No newline at end of file diff --git a/init.rb b/init.rb index 9fb00e5b..511675ab 100644 --- a/init.rb +++ b/init.rb @@ -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",