Merge branch 'MDL-87190-501' of https://github.com/timhunt/moodle into MOODLE_501_STABLE

This commit is contained in:
Huong Nguyen
2026-02-25 10:57:57 +07:00
3 changed files with 33 additions and 12 deletions
@@ -886,6 +886,8 @@ class page_requirements_manager {
['sizegb', 'moodle'], ['sizemb', 'moodle'], ['sizekb', 'moodle'], ['sizeb', 'moodle'],
['maxareabytesreached', 'moodle'], ['serverconnection', 'error'],
['changesmadereallygoaway', 'moodle'], ['complete', 'moodle'],
['upload_error_folders_not_supported', 'repository_upload'],
['upload_error_folders_not_supported_title', 'repository_upload'],
],
];
break;
+29 -12
View File
@@ -325,8 +325,10 @@ M.form_dndupload.init = function(Y, options) {
this.hide_drop_target();
var files = e._event.dataTransfer.files;
const items = e._event.dataTransfer.items;
let options;
if (this.filemanager) {
var options = {
options = {
files: files,
options: this.options,
repositoryid: this.repositoryid,
@@ -346,9 +348,6 @@ M.form_dndupload.init = function(Y, options) {
callbackClearProgress: Y.bind('clear_progress', this),
callbackStartProgress: Y.bind('startProgress', this),
};
this.show_progress();
var uploader = new dnduploader(options);
uploader.start_upload();
} else {
if (files.length >= 1) {
options = {
@@ -371,11 +370,24 @@ M.form_dndupload.init = function(Y, options) {
callbackClearProgress: Y.bind('clear_progress', this),
callbackStartProgress: Y.bind('startProgress', this),
};
this.show_progress();
uploader = new dnduploader(options);
uploader.start_upload();
}
}
let uploader = new dnduploader(options);
for (let i = 0; i < items.length; i++) {
let entry = items[i].webkitGetAsEntry();
if (!entry) {
continue;
}
if (entry.isDirectory && entry.name) {
uploader.print_msg(
M.util.get_string('upload_error_folders_not_supported', 'repository_upload', entry.name),
'error',
'uploaderrorfoldersnotsupported');
return false;
}
}
this.show_progress();
uploader.start_upload();
return false;
},
@@ -652,16 +664,21 @@ M.form_dndupload.init = function(Y, options) {
},
/**
* Display a message in a popup
* @param string msg - the message to display
* @param string type - 'error' or 'info'
* Display a message in a popup dialog.
*
* @param {string} msg - The message text to display.
* @param {string} type - The message type, 'error' or 'info'.
* @param {string} errorCode - The associated error code (optional).
*/
print_msg: function(msg, type) {
print_msg: function(msg, type, errorCode) {
var header = M.util.get_string('error', 'moodle');
if (type != 'error') {
type = 'info'; // one of only two types excepted
type = 'info'; // One of only two types excepted.
header = M.util.get_string('info', 'moodle');
}
if (errorCode === 'uploaderrorfoldersnotsupported') {
header = M.util.get_string('upload_error_folders_not_supported_title', 'repository_upload');
}
if (!this.msg_dlg) {
this.msg_dlg_node = Y.Node.create(M.core_filepicker.templates.message);
this.msg_dlg_node.generateID();
@@ -34,5 +34,7 @@ $string['upload_error_no_file'] = 'No file was uploaded.';
$string['upload_error_no_tmp_dir'] = 'PHP is missing a temporary folder.';
$string['upload_error_cant_write'] = 'Failed to write file to disk.';
$string['upload_error_extension'] = 'A PHP extension stopped the file upload.';
$string['upload_error_folders_not_supported'] = 'Compress the folder into a ZIP file to upload it.';
$string['upload_error_folders_not_supported_title'] = 'This folder can\'t be uploaded';
$string['upload_error_invalid_file'] = 'The file \'{$a}\' is either empty or a folder. To upload folders zip them first.';
$string['privacy:metadata'] = 'The Upload a file repository plugin does not store or transmit any personal data.';