Branch 'roundcubemail-plugins-kolab-3.1' - plugins/kolab_files
Aleksander Machniak
machniak at kolabsys.com
Fri Apr 25 20:23:18 CEST 2014
plugins/kolab_files/kolab_files.js | 14 +++++++++++++-
plugins/kolab_files/lib/kolab_files_engine.php | 3 ++-
plugins/kolab_files/localization/en_US.inc | 1 +
3 files changed, 16 insertions(+), 2 deletions(-)
New commits:
commit ee8b220e44e3dded5f500502caa480a1aee2197d
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Fri Apr 25 20:22:27 2014 +0200
Check upload size limit also before upload (Bug #2996)
diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js
index 3b8a58e..e3435e8 100644
--- a/plugins/kolab_files/kolab_files.js
+++ b/plugins/kolab_files/kolab_files.js
@@ -1462,11 +1462,23 @@ function kolab_files_ui()
// file upload request
this.file_upload = function(form)
{
- var form = $(form),
+ var i, size = 0, maxsize = rcmail.env.files_max_upload,
+ form = $(form),
field = $('input[type=file]', form).get(0),
files = field.files ? field.files.length : field.value ? 1 : 0;
if (files) {
+ // check upload max size
+ if (field.files && maxsize) {
+ for (i=0; i < files; i++)
+ size += field.files[i].size;
+
+ if (size > maxsize) {
+ alert(rcmail.get_label('kolab_files.uploadsizeerror').replace('$size', this.file_size(maxsize)));
+ return;
+ }
+ }
+
// submit form and read server response
this.file_upload_form(form, 'file_upload', function(event) {
var doc, response;
diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php
index 67905b0..e48ccf8 100644
--- a/plugins/kolab_files/lib/kolab_files_engine.php
+++ b/plugins/kolab_files/lib/kolab_files_engine.php
@@ -623,7 +623,7 @@ class kolab_files_engine
{
$this->plugin->add_label(
'folderdeleting', 'folderdeleteconfirm', 'folderdeletenotice',
- 'uploading', 'attaching',
+ 'uploading', 'attaching', 'uploadsizeerror',
'filedeleting', 'filedeletenotice', 'filedeleteconfirm',
'filemoving', 'filemovenotice', 'filemoveconfirm', 'filecopying', 'filecopynotice',
'collection_audio', 'collection_video', 'collection_image', 'collection_document',
@@ -633,6 +633,7 @@ class kolab_files_engine
$this->rc->output->set_pagetitle($this->plugin->gettext('files'));
$this->rc->output->set_env('file_mimetypes', $this->get_mimetypes());
$this->rc->output->set_env('files_quota', $_SESSION['kolab_files_caps']['QUOTA']);
+ $this->rc->output->set_env('files_max_upload', $_SESSION['kolab_files_caps']['MAX_UPLOAD']);
$this->rc->output->send('kolab_files.files');
}
diff --git a/plugins/kolab_files/localization/en_US.inc b/plugins/kolab_files/localization/en_US.inc
index 5023002..1f6e618 100644
--- a/plugins/kolab_files/localization/en_US.inc
+++ b/plugins/kolab_files/localization/en_US.inc
@@ -58,6 +58,7 @@ $labels['filedeleteconfirm'] = 'Are you sure you want to delete selected files?'
$labels['filedeletenotice'] = 'File(s) deleted successfully.';
$labels['filemovenotice'] = 'File(s) moved successfully.';
$labels['filecopynotice'] = 'File(s) copied successfully.';
+$labels['uploadsizeerror'] = 'Maximum file size ($size) exceeded!';
$labels['allfolders'] = 'search in all folders';
$labels['fileskip'] = 'Skip';
More information about the commits
mailing list