MDL-27919 Fixes 'undefined' message and similar problems when selecting a

recent file, server file or when renaming a file being uploaded with the same
name as a previous one.
This commit is contained in:
Jamie Pratt
2011-09-18 13:22:35 +07:00
parent 5d2db8acc8
commit 794cc7e1cf
2 changed files with 10 additions and 4 deletions
+4 -2
View File
@@ -222,14 +222,16 @@ M.core_filepicker.init = function(Y, options) {
}
this.cancel();
scope.hide();
data.client_id = client_id;
var formcallback_scope = null;
if (scope.options.magicscope) {
formcallback_scope = scope.options.magicscope;
} else {
formcallback_scope = scope;
}
scope.options.formcallback.apply(formcallback_scope, [data]);
var fileinfo = {'client_id':client_id,
'url':data.newfile.url,
'file':data.newfile.filename};
scope.options.formcallback.apply(formcallback_scope, [fileinfo]);
}
var handleCancel = function() {
// Delete tmp file
+6 -2
View File
@@ -195,7 +195,7 @@ switch ($action) {
// use external link
$link = $repo->get_link($source);
$info = array();
$info['filename'] = $saveas_filename;
$info['file'] = $saveas_filename;
$info['type'] = 'link';
$info['url'] = $link;
echo json_encode($info);
@@ -206,6 +206,9 @@ switch ($action) {
// (local, user, coursefiles, recent)
if ($repo->has_moodle_files()) {
$fileinfo = $repo->copy_to_area($source, $itemid, $saveas_path, $saveas_filename);
if (!isset($fileinfo['event'])) {
$fileinfo['file'] = $fileinfo['title'];
}
echo json_encode($fileinfo);
die;
}
@@ -261,7 +264,8 @@ switch ($action) {
$newfilepath = required_param('newfilepath', PARAM_PATH);
$newfilename = required_param('newfilename', PARAM_FILE);
echo json_encode(repository::overwrite_existing_draftfile($itemid, $filepath, $filename, $newfilepath, $newfilename));
$info = repository::overwrite_existing_draftfile($itemid, $filepath, $filename, $newfilepath, $newfilename);
echo json_encode($info);
break;
case 'deletetmpfile':