From 8a3e6a5604fe5d322e615a1f85c03fbb8fc74d0e Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Mon, 8 Mar 2010 16:49:51 +0000 Subject: [PATCH] "MDL-13766, fixed maxbytes limit" --- lib/form/filemanager.php | 4 ++-- repository/filepicker.js | 1 + repository/repository_ajax.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/form/filemanager.php b/lib/form/filemanager.php index 270b0fce1e1..ca00ee659b0 100644 --- a/lib/form/filemanager.php +++ b/lib/form/filemanager.php @@ -42,7 +42,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element { $this->_options[$name] = $value; } } - if (!empty($options['maxbytes'])) { + if (empty($options['maxbytes'])) { $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']); } parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); @@ -152,7 +152,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element { $options = file_get_draft_area_files($draftitemid); $options->mainfile = $this->_options['mainfile']; - $options->maxbytes = $this->getMaxbytes(); + $options->maxbytes = $this->_options['maxbytes']; $options->maxfiles = $this->getMaxfiles(); $options->client_id = $client_id; $options->filecount = $filecount; diff --git a/repository/filepicker.js b/repository/filepicker.js index cc3bd0a9846..fc84df9abe0 100644 --- a/repository/filepicker.js +++ b/repository/filepicker.js @@ -95,6 +95,7 @@ M.core_filepicker.init = function(Y, options) { params['sesskey']=M.cfg.sesskey; params['client_id'] = args.client_id; params['itemid'] = this.options.itemid?this.options.itemid:0; + params['maxbytes'] = this.options.maxbytes?this.options.maxbytes:-1; if (args['params']) { for (i in args['params']) { params[i] = args['params'][i]; diff --git a/repository/repository_ajax.php b/repository/repository_ajax.php index 3eb4955a95c..df143c05e4d 100755 --- a/repository/repository_ajax.php +++ b/repository/repository_ajax.php @@ -270,7 +270,7 @@ EOD; break; case 'upload': try { - $result = $repo->upload(); + $result = $repo->upload($maxbytes); $result['client_id'] = $client_id; echo json_encode($result); } catch (Exception $e){