From 6b6b8b94035657ea34e242286f37bb8e6a35ef5e Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Tue, 9 Sep 2014 10:01:35 +0800 Subject: [PATCH 1/2] MDL-46834 filepicker: dnd upload should respect the current context id --- lib/form/dndupload.js | 6 +++++- lib/form/filemanager.js | 3 ++- lib/form/filepicker.js | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/form/dndupload.js b/lib/form/dndupload.js index f93f261c000..60b78bb4091 100644 --- a/lib/form/dndupload.js +++ b/lib/form/dndupload.js @@ -30,7 +30,7 @@ M.form_dndupload.init = function(Y, options) { Y: null, // URL for upload requests url: M.cfg.wwwroot + '/repository/repository_ajax.php?action=upload', - // options may include: itemid, acceptedtypes, maxfiles, maxbytes, clientid, repositoryid, author + // options may include: itemid, acceptedtypes, maxfiles, maxbytes, clientid, repositoryid, author, contextid options: {}, // itemid used for repository upload itemid: null, @@ -69,6 +69,7 @@ M.form_dndupload.init = function(Y, options) { * maxbytes: maximum size of files allowed in this form * areamaxbytes: maximum combined size of files allowed in this form * clientid: unqiue id of this form field used for html elements + * contextid: id of the current cotnext * containerid: htmlid of container * repositories: array of repository objects passed from filepicker * filemanager: filemanager element we are working with @@ -888,6 +889,9 @@ M.form_dndupload.init = function(Y, options) { if (overwrite) { formdata.append('overwrite', 1); } + if (this.options.contextid) { + formdata.append('ctx_id', this.options.contextid); + } // Accepted types can be either a string or an array, but an array is // expected in the processing script, so make sure we are sending an array diff --git a/lib/form/filemanager.js b/lib/form/filemanager.js index 4b9a91263d8..0a2c332b40d 100644 --- a/lib/form/filemanager.js +++ b/lib/form/filemanager.js @@ -1056,7 +1056,8 @@ M.form_filemanager.init = function(Y, options) { areamaxbytes: options.areamaxbytes, itemid: options.itemid, repositories: manager.filepicker_options.repositories, - containerid: manager.dndcontainer.get('id') + containerid: manager.dndcontainer.get('id'), + contextid: options.context.id }; M.form_dndupload.init(Y, dndoptions); }; diff --git a/lib/form/filepicker.js b/lib/form/filepicker.js index e3632e2f07e..d13a9cda403 100644 --- a/lib/form/filepicker.js +++ b/lib/form/filepicker.js @@ -57,7 +57,8 @@ M.form_filepicker.init = function(Y, options) { repositories: options.repositories, formcallback: options.formcallback, containerprefix: '#file_info_', - containerid: 'file_info_'+options.client_id + containerid: 'file_info_'+options.client_id, + contextid: options.context.id }; M.form_dndupload.init(Y, dndoptions); }; From 9ba4fc1585fba3febd8b6179b044c9119b45fcfc Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 4 Sep 2014 15:46:20 +0800 Subject: [PATCH 2/2] MDL-46834 dndupload: Hide dnd message when user cant upload files --- lib/form/dndupload.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/form/dndupload.js b/lib/form/dndupload.js index 60b78bb4091..b53446d6a6c 100644 --- a/lib/form/dndupload.js +++ b/lib/form/dndupload.js @@ -83,15 +83,17 @@ M.form_dndupload.init = function(Y, options) { Y.one('body').addClass('dndnotsupported'); return; // Browser does not support the required functionality } - Y.one('body').addClass('dndsupported'); // try and retrieve enabled upload repository this.repositoryid = this.get_upload_repositoryid(options.repositories); if (!this.repositoryid) { + Y.one('body').addClass('dndnotsupported'); return; // no upload repository is enabled to upload to } + Y.one('body').addClass('dndsupported'); + this.options = options; this.acceptedtypes = options.acceptedtypes; this.clientid = options.clientid;