Skip to content

Commit

Permalink
Merge branch 'MDL-77838-402' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_402_STABLE
  • Loading branch information
HuongNV13 committed Apr 3, 2024
2 parents 6a008f1 + f512681 commit c0e8e44
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions repository/lib.php
Expand Up @@ -3267,7 +3267,7 @@ function repository_delete_selected_files($context, string $component, string $f
* @param string $filearea filearea
* @param int $itemid the item id
* @param array $files Array of files object with each item having filename/filepath as values
* @return array $return Array of strings matching up to the parent directory of the deleted files
* @return false|stdClass $return Object containing URL of zip archive and a file path
* @throws coding_exception
*/
function repository_download_selected_files($context, string $component, string $filearea, $itemid, array $files) {
Expand All @@ -3284,10 +3284,6 @@ function repository_download_selected_files($context, string $component, string
$filename = $selectedfile->filename ? clean_filename($selectedfile->filename) : '.'; // Default to '.' for root.
$filepath = clean_param($selectedfile->filepath, PARAM_PATH); // Default to '/' for downloadall.
$filepath = file_correct_filepath($filepath);
$area = file_get_draft_area_info($itemid, $filepath);
if ($area['filecount'] == 0 && $area['foldercount'] == 0) {
continue;
}

$storedfile = $fs->get_file($context->id, $component, $filearea, $itemid, $filepath, $filename);
// If it is empty we are downloading a directory.
Expand All @@ -3301,16 +3297,16 @@ function repository_download_selected_files($context, string $component, string
$filestoarchive[$archivefile] = $storedfile;
}
$zippedfile = get_string('files') . '.zip';
if ($newfile =
$zipper->archive_to_storage(
if ($zipper->archive_to_storage(
$filestoarchive,
$context->id,
$component,
$filearea,
$newdraftitemid,
"/",
$zippedfile, $USER->id)
) {
$zippedfile,
$USER->id,
)) {
$return = new stdClass();
$return->fileurl = moodle_url::make_draftfile_url($newdraftitemid, '/', $zippedfile)->out();
$return->filepath = $filepath;
Expand Down

0 comments on commit c0e8e44

Please sign in to comment.