Skip to content

Commit

Permalink
MDL-13766, filemanager, don't download empty draft area
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng Cai committed May 3, 2010
1 parent 63c9d71 commit 7210e88
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions files/files_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
case 'downloaddir':
$zipper = new zip_packer();
$fs = get_file_storage();
$draftarea = file_get_draft_area_info($itemid);
if ($draftarea['filecount'] == 0) {
echo json_encode(false);
die;
}

$stored_file = $fs->get_file($user_context->id, $filearea, $itemid, $filepath, '.');
if ($filepath === '/') {
Expand Down
1 change: 1 addition & 0 deletions lang/en/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
$string['download'] = 'Download';
$string['downloadfolder'] = 'Download this folder';
$string['downloadsucc'] = 'The file has been downloaded successfully';
$string['draftareanofiles'] = 'Cannot be downloaed because there is no files attached';
$string['editrepositoryinstance'] = 'Edit repository instance';
$string['emptylist'] = 'Empty result';
$string['emptytype'] = 'Cannot create repository type: type name is empty';
Expand Down
12 changes: 8 additions & 4 deletions lib/form/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,14 @@ M.form_filemanager.init = function(Y, options) {
action: 'downloaddir',
scope: scope,
callback: function(id, obj, args) {
scope.refresh(obj.filepath);
var win = window.open(obj.fileurl, 'fm-download-folder');
if (!win) {
alert(M.str.repository.popupblockeddownload);
if (obj) {
scope.refresh(obj.filepath);
var win = window.open(obj.fileurl, 'fm-download-folder');
if (!win) {
alert(M.str.repository.popupblockeddownload);
}
} else {
alert(M.str.repository.draftareanofiles);
}
}
});
Expand Down
1 change: 1 addition & 0 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,7 @@ function print_filemanager($options, $return = false) {
$PAGE->requires->string_for_js('confirmdeletefile', 'repository');
$PAGE->requires->string_for_js('nopathselected', 'repository');
$PAGE->requires->string_for_js('popupblockeddownload', 'repository');
$PAGE->requires->string_for_js('draftareanofiles', 'repository');
$PAGE->requires->string_for_js('path', 'moodle');
// language strings
$straddfile = get_string('add', 'repository') . '...';
Expand Down

0 comments on commit 7210e88

Please sign in to comment.