Merge branch 'MDL-44626-master' of git://github.com/andrewnicols/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 15 Feb 2016 10:36:20 +0000 (10:36 +0000)
committerDan Poltawski <dan@moodle.com>
Mon, 15 Feb 2016 10:36:20 +0000 (10:36 +0000)
lang/en/repository.php
lib/form/dndupload.js
lib/moodlelib.php
webservice/tests/externallib_test.php

index 60e4628..a0e32a3 100644 (file)
@@ -111,7 +111,7 @@ $string['error'] = 'An unknown error occurred!';
 $string['errordoublereference'] = 'Unable to overwrite file with a shortcut/alias because shortcuts to this file already exist.';
 $string['errornotyourfile'] = 'You cannot pick file which is not added by your';
 $string['erroruniquename'] = 'Repository instance name should be unique';
-$string['errorpostmaxsize'] = 'The uploaded file may exceed the post_max_size directive in php.ini.';
+$string['errorpostmaxsize'] = 'The file you tried to upload is too large for the server to process.';
 $string['errorwhilecommunicatingwith'] = 'Error while communicating with the repository \'{$a}\'.';
 $string['errorwhiledownload'] = 'An error occurred while downloading the file: {$a}';
 $string['existingrepository'] = 'This repository already exists';
index e29d3c0..de0ee97 100644 (file)
@@ -876,7 +876,6 @@ M.form_dndupload.init = function(Y, options) {
 
             // Prepare the data to send
             var formdata = new FormData();
-            formdata.append('action', 'upload');
             formdata.append('repo_upload_file', file); // The FormData class allows us to attach a file
             formdata.append('sesskey', M.cfg.sesskey);
             formdata.append('repo_id', this.repositoryid);
@@ -905,8 +904,14 @@ M.form_dndupload.init = function(Y, options) {
                 formdata.append('accepted_types[]', this.options.acceptedtypes);
             }
 
-            // Send the file & required details
-            xhr.open("POST", this.api, true);
+            // Send the file & required details.
+            var uploadUrl = this.api;
+            if (uploadUrl.indexOf('?') !== -1) {
+                uploadUrl += '&action=upload';
+            } else {
+                uploadUrl += '?action=upload';
+            }
+            xhr.open("POST", uploadUrl, true);
             xhr.send(formdata);
             return true;
         }
index 9233dbb..b2c57f6 100644 (file)
@@ -6192,7 +6192,7 @@ function get_user_max_upload_file_size($context, $sitebytes = 0, $coursebytes =
     }
 
     if (has_capability('moodle/course:ignorefilesizelimits', $context, $user)) {
-        return USER_CAN_IGNORE_FILE_SIZE_LIMITS;
+        return get_max_upload_file_size(USER_CAN_IGNORE_FILE_SIZE_LIMITS);
     }
 
     return get_max_upload_file_size($sitebytes, $coursebytes, $modulebytes);
index 5c80986..9d98d35 100644 (file)
@@ -151,7 +151,9 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
         $siteinfo = external_api::clean_returnvalue(core_webservice_external::get_site_info_returns(), $siteinfo);
 
         $this->assertEquals(0, $siteinfo['userquota']);
-        $this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']);
+
+        // The max_size is dependant upon the post_max_size, and upload_max_filesize values in php.ini.
+        $this->assertEquals(get_max_upload_file_size(USER_CAN_IGNORE_FILE_SIZE_LIMITS), $siteinfo['usermaxuploadfilesize']);
         $this->assertEquals(true, $siteinfo['usercanmanageownfiles']);
 
         $this->assertEquals(HOMEPAGE_SITE, $siteinfo['userhomepage']);