Merge branch 'wip-MDL-46834-master' of git://github.com/marinaglancy/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 9 Sep 2014 07:06:40 +0000 (08:06 +0100)
committerDan Poltawski <dan@moodle.com>
Tue, 9 Sep 2014 07:06:40 +0000 (08:06 +0100)
lib/form/dndupload.js
lib/form/filemanager.js
lib/form/filepicker.js

index f93f261..b53446d 100644 (file)
@@ -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
@@ -82,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;
@@ -888,6 +891,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
index 166e5a3..7f3f74f 100644 (file)
@@ -1066,7 +1066,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);
 };
index e3632e2..d13a9cd 100644 (file)
@@ -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);
 };