diff --git a/admin/settings/development.php b/admin/settings/development.php index 9d7b5a09981..dcddf32a903 100644 --- a/admin/settings/development.php +++ b/admin/settings/development.php @@ -13,6 +13,10 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', new lang_string('enablesafebrowserintegration', 'admin'), new lang_string('configenablesafebrowserintegration', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('enablegroupmembersonly', new lang_string('enablegroupmembersonly', 'admin'), new lang_string('configenablegroupmembersonly', 'admin'), 0)); + $dndopts = array(0 => new lang_string('dnduploadfiles', 'admin'), + 1 => new lang_string('dnduploadfilestextlink', 'admin')); + $temp->add(new admin_setting_configselect('dndallowtextandlinks', new lang_string('dndallowtextandlinks', 'admin'), new lang_string('configdndallowtextandlinks', 'admin'), 0, $dndopts)); + $ADMIN->add('experimental', $temp); // "debugging" settingpage diff --git a/course/dndupload.js b/course/dndupload.js index bdfe18a99d9..9b7c4e4a6fe 100644 --- a/course/dndupload.js +++ b/course/dndupload.js @@ -903,34 +903,6 @@ M.course_dndupload = { } }; - if (type == 'text/html') { - // If this was html content dragged from Chrome => Firefox, we will - // need to fix the byte order of the content. - if (this.Y.UA.gecko > 0) { - if (contents.indexOf('<') == -1) { - // There are no html tags in this content => it probably needs fixing. - var codes = new Array(); - for (i=0; i it is probably correct. - contents = fixedcontents; - } - } - } - } - // Prepare the data to send var formData = new FormData(); formData.append('contents', contents); @@ -941,19 +913,6 @@ M.course_dndupload = { formData.append('type', type); formData.append('module', module); - if (type == 'text/html') { - // This html content might have been dragged from Firefox to Chrome (in Linux). - // Need to provide an extra fixed version of the contents, in case the original does not upload. - if (this.Y.UA.webkit > 0 && this.Y.UA.os == 'linux') { - var fixedcontents = ''; - for (i=0; iprocess($displayname, $contents); diff --git a/course/dnduploadlib.php b/course/dnduploadlib.php index 402c91f66ba..d82da3544e2 100644 --- a/course/dnduploadlib.php +++ b/course/dnduploadlib.php @@ -304,17 +304,21 @@ class dndupload_handler { * @return object Data to pass on to Javascript code */ public function get_js_data() { + global $CFG; + $ret = new stdClass; // Sort the types by priority. uasort($this->types, array($this, 'type_compare')); $ret->types = array(); - foreach ($this->types as $type) { - if (empty($type->handlers)) { - continue; // Skip any types without registered handlers. + if ($CFG->dndallowtextandlinks) { + foreach ($this->types as $type) { + if (empty($type->handlers)) { + continue; // Skip any types without registered handlers. + } + $ret->types[] = $type; } - $ret->types[] = $type; } $ret->filehandlers = $this->filehandlers; @@ -436,6 +440,10 @@ class dndupload_ajax_processor { if ($content != null) { throw new moodle_exception('fileuploadwithcontent', 'moodle'); } + } else { + if (empty($content)) { + throw new moodle_exception('dnduploadwithoutcontent', 'moodle'); + } } require_sesskey(); diff --git a/lang/en/admin.php b/lang/en/admin.php index 5cee004eef8..9ae4445a51a 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -183,6 +183,7 @@ $string['configdenyemailaddresses'] = 'To deny email addresses from particular d $string['configenabledevicedetection'] = 'Enables detection of mobiles, smartphones, tablets or default devices (desktop PCs, laptops, etc) for the application of themes and other features.'; $string['configdisableuserimages'] = 'Disable the ability for users to change user profile images.'; $string['configdisplayloginfailures'] = 'This will display information to selected users about previous failed logins.'; +$string['configdndallowtextandlinks'] = 'Enable or disable the dragging and dropping of text and links onto a course page, alongside the dragging and dropping of files. Note that the dragging of text into Firefox or between different browsers is unreliable and may result in no data being uploaded, or corrupted text being uploaded.'; $string['configdocroot'] = 'Defines the path to the Moodle Docs. You can change this if you wish to have your own custom online documentation. However, if you do that make sure that the paths in your documentation follow the same format as http://docs.moodle.org.'; $string['configdoctonewwindow'] = 'If you enable this, then links to Moodle Docs will be shown in a new window.'; $string['configeditordictionary'] = 'This value will be used if aspell doesn\'t have dictionary for users own language.'; @@ -431,6 +432,9 @@ $string['devicetype'] = 'Device type'; $string['disableuserimages'] = 'Disable user profile images'; $string['displayerrorswarning'] = 'Enabling the PHP setting display_errors is not recommended on production sites because some error messages may reveal sensitive information about your server.'; $string['displayloginfailures'] = 'Display login failures to'; +$string['dndallowtextandlinks'] = 'Drag and drop upload allows'; +$string['dnduploadfiles'] = 'files only'; +$string['dnduploadfilestextlink'] = 'files, text and links'; $string['docroot'] = 'Moodle Docs document root'; $string['doctonewwindow'] = 'Open in new window'; $string['download'] = 'Download'; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 8950c320020..859e874dd25 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -466,6 +466,7 @@ $string['dndenabled'] = 'Drag and drop available'; $string['dndenabled_help'] = 'You can drag one or more files from your desktop and drop them onto the box below to upload them.
Note: this may not work with other web browsers'; $string['dndenabled_insentence'] = 'drag and drop available'; $string['dndenabled_inbox'] = 'drag and drop files here to upload them'; +$string['dnduploadwithoutcontent'] = 'This upload does not have any content'; $string['dndworkingfiletextlink'] = 'Drag and drop files, text or links onto course sections to upload them'; $string['dndworkingfilelink'] = 'Drag and drop files or links onto course sections to upload them'; $string['dndworkingfiletext'] = 'Drag and drop files or text onto course sections to upload them';