Skip to content

Commit

Permalink
MDL-27919 Fixes 'undefined' message and similar problems when selecti…
Browse files Browse the repository at this point in the history
…ng a

recent file, server file or when renaming a file being uploaded with the same
name as a previous one.
  • Loading branch information
jamiepratt authored and Sam Hemelryk committed Oct 31, 2011
1 parent 7a6d43a commit 4491532
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions repository/filepicker.js
Expand Up @@ -222,14 +222,16 @@ M.core_filepicker.init = function(Y, options) {
} }
this.cancel(); this.cancel();
scope.hide(); scope.hide();
data.client_id = client_id;
var formcallback_scope = null; var formcallback_scope = null;
if (scope.options.magicscope) { if (scope.options.magicscope) {
formcallback_scope = scope.options.magicscope; formcallback_scope = scope.options.magicscope;
} else { } else {
formcallback_scope = scope; 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() { var handleCancel = function() {
// Delete tmp file // Delete tmp file
Expand Down
8 changes: 6 additions & 2 deletions repository/repository_ajax.php
Expand Up @@ -195,7 +195,7 @@
// use external link // use external link
$link = $repo->get_link($source); $link = $repo->get_link($source);
$info = array(); $info = array();
$info['filename'] = $saveas_filename; $info['file'] = $saveas_filename;
$info['type'] = 'link'; $info['type'] = 'link';
$info['url'] = $link; $info['url'] = $link;
echo json_encode($info); echo json_encode($info);
Expand All @@ -215,6 +215,9 @@
throw new file_exception('maxbytes'); throw new file_exception('maxbytes');
} }
$fileinfo = $repo->copy_to_area($source, $itemid, $saveas_path, $saveas_filename); $fileinfo = $repo->copy_to_area($source, $itemid, $saveas_path, $saveas_filename);
if (!isset($fileinfo['event'])) {
$fileinfo['file'] = $fileinfo['title'];
}
echo json_encode($fileinfo); echo json_encode($fileinfo);
die; die;
} }
Expand Down Expand Up @@ -270,7 +273,8 @@
$newfilepath = required_param('newfilepath', PARAM_PATH); $newfilepath = required_param('newfilepath', PARAM_PATH);
$newfilename = required_param('newfilename', PARAM_FILE); $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; break;


case 'deletetmpfile': case 'deletetmpfile':
Expand Down

0 comments on commit 4491532

Please sign in to comment.