Skip to content
Browse files

MDL-27919 Fixes 'undefined' message and similar problems when selecti…

…ng a

recent file, server file or when renaming a file being uploaded with the same
name as a previous one.
  • Loading branch information...
1 parent 7a6d43a commit 44915324c80f26187dfc7abd1567c80f18699368 @jamiepratt jamiepratt committed with Sam Hemelryk Sep 18, 2011
Showing with 10 additions and 4 deletions.
  1. +4 −2 repository/filepicker.js
  2. +6 −2 repository/repository_ajax.php
View
6 repository/filepicker.js
@@ -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
View
8 repository/repository_ajax.php
@@ -195,7 +195,7 @@
// 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);
@@ -215,6 +215,9 @@
throw new file_exception('maxbytes');
}
$fileinfo = $repo->copy_to_area($source, $itemid, $saveas_path, $saveas_filename);
+ if (!isset($fileinfo['event'])) {
+ $fileinfo['file'] = $fileinfo['title'];
+ }
echo json_encode($fileinfo);
die;
}
@@ -270,7 +273,8 @@
$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':

0 comments on commit 4491532

Please sign in to comment.
Something went wrong with that request. Please try again.