Skip to content

Commit

Permalink
Fix file API integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dasistwas committed Jan 23, 2024
1 parent bb28a11 commit 98b0341
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,13 @@ function mod_datalynx_pluginfile($course, $cm, $context, $filearea, $args, $forc
$oldpath = "/$context->id/mod_dataform/$filearea/$contentid/$relativepath";

$fs = get_file_storage();
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) || $file->is_directory()) {
if (!$file = $fs->get_file_by_hash(sha1($oldpath)) || $file->is_directory()) {
$file = $fs->get_file_by_hash(sha1($fullpath));
if (!$file || $file->is_directory()) {
$file = $fs->get_file_by_hash(sha1($oldpath));
if (!$file || $file->is_directory()) {
return false;
}
}

// Finally send the file.
send_stored_file($file, 0, 0, false); // Download MUST be forced - security!
}
Expand Down

0 comments on commit 98b0341

Please sign in to comment.