Skip to content

Commit

Permalink
Update #86by49k22 - code reformatted and moodle code style followed
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaalshaikh committed Sep 10, 2024
1 parent 5577c0f commit 264a575
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@
* @param array $args
* @param bool $forcedownload
* @param array $options
*
* @throws coding_exception
* @throws moodle_exception
* @throws require_login_exception
*/
function block_fastnav_pluginfile($course, $recordorcm, $context, $filearea, $args, $forcedownload, array $options = []) {
function block_fastnav_pluginfile(stdClass $course, $recordorcm, stdClass $context, string $filearea, array $args, $forcedownload,
array $options = []): void {
global $CFG;

if ($context->contextlevel !== CONTEXT_BLOCK) {
Expand All @@ -57,21 +54,28 @@ function block_fastnav_pluginfile($course, $recordorcm, $context, $filearea, $ar
$parentcontext = $context->get_parent_context();
// Check if category is visible and user can view this category.
if (($parentcontext->contextlevel === CONTEXT_COURSECAT)
&& !core_course_category::get($parentcontext->instanceid, IGNORE_MISSING)) {
&& !core_course_category::get(id: $parentcontext->instanceid, strictness: IGNORE_MISSING)) {
send_file_not_found();
}
}

$fs = get_file_storage();
$itemid = (int) array_shift($args);
$filename = array_pop($args);
$itemid = (int) array_shift(array: $args);
$filename = array_pop(array: $args);

$file = $fs->get_file($context->id, 'block_fastnav', $filearea, $itemid, '/', $filename);
$file = $fs->get_file(
contextid: $context->id,
component: 'block_fastnav',
filearea: $filearea,
itemid: $itemid,
filepath: '/',
filename: $filename
);

if (!$file || $file->is_directory()) {
send_file_not_found();
}

\core\session\manager::write_close();
send_stored_file($file, null, 0, true, $options);
send_stored_file(storedfile: $file, forcedownload: true, options: $options);
}

0 comments on commit 264a575

Please sign in to comment.