Index: repository/filepicker.js =================================================================== --- repository/filepicker.js (revision 16017) +++ repository/filepicker.js (revision ) @@ -210,16 +210,20 @@ // filemanager do nothing if (scope.options.editor_target && scope.options.env == 'editor') { scope.options.editor_target.value = data.existingfile.url; + if (scope.options.editor_target.onchange != undefined) { - scope.options.editor_target.onchange(); - } - } + scope.options.editor_target.onchange(); + } + } + } }, true); } var handleRename = function() { if (scope.options.editor_target && scope.options.env == 'editor') { scope.options.editor_target.value = data.newfile.url; + if (scope.options.editor_target.onchange != undefined) { - scope.options.editor_target.onchange(); - } + scope.options.editor_target.onchange(); + } + } this.cancel(); scope.hide(); data.client_id = client_id; @@ -671,14 +675,17 @@ this.wait('download', title); this.request({ action:'download', + scope: scope, client_id: client_id, repository_id: repository_id, 'params': params, callback: function(id, obj, args) { if (scope.options.editor_target && scope.options.env=='editor') { scope.options.editor_target.value=obj.url; + if (scope.options.editor_target.onchange != undefined) { - scope.options.editor_target.onchange(); - } + scope.options.editor_target.onchange(); + } + } scope.hide(); obj.client_id = client_id; var formcallback_scope = null; @@ -1182,8 +1189,10 @@ callback: function(id, o, args) { if (scope.options.editor_target&&scope.options.env=='editor') { scope.options.editor_target.value=o.url; + if (scope.options.editor_target.onchange != undefined) { - scope.options.editor_target.onchange(); - } + scope.options.editor_target.onchange(); + } + } scope.hide(); o.client_id = client_id; var formcallback_scope = null; Index: repository/repository_ajax.php =================================================================== --- repository/repository_ajax.php (revision 15172) +++ repository/repository_ajax.php (revision ) @@ -174,9 +174,15 @@ $mimetypes[] = mimeinfo('type', $type); } if (!in_array(mimeinfo('type', $saveas_filename), $mimetypes)) { - throw new moodle_exception('invalidfiletype', 'repository', '', get_string(mimeinfo('type', $saveas_filename), 'mimetypes')); + $mimetype = mimeinfo('type', $saveas_filename); + if (get_string_manager()->string_exists($mimetype, 'mimetypes')) { + $a = get_string($mimetype, 'mimetypes'); + } else { + $a = $mimetype; - } + } + throw new moodle_exception('invalidfiletype', 'repository', '', $a); - } + } + } // We have two special repository type need to deal with // local and recent plugins don't added new files to moodle, just add new records to database