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 committed Sep 18, 2011
1 parent 5d2db8a commit 794cc7e
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions repository/repository_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -206,6 +206,9 @@
// (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;
}
Expand Down Expand Up @@ -261,7 +264,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':
Expand Down

0 comments on commit 794cc7e

Please sign in to comment.