From f8b21555ce992dabbd7bd5281bb43d99e77cc1e5 Mon Sep 17 00:00:00 2001 From: Luuk Verhoeven Date: Tue, 2 Jan 2024 17:14:33 +0100 Subject: [PATCH] Update #1 less strict access check for files, use same logic as mod_book --- lib.php | 31 ++++++++++++++++++++----------- version.php | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib.php b/lib.php index 9583438..bdf5208 100644 --- a/lib.php +++ b/lib.php @@ -125,7 +125,7 @@ function stackview_get_file_areas($course, $cm, $context) { * * @param object $course The course object. * @param object $cm The course module object. - * @param object $context The mod_stackview's context. + * @param context $context The mod_stackview's context. * @param string $filearea The name of the file area. * @param array $args Extra arguments (itemid, path). * @param bool $forcedownload Whether or not force download. @@ -134,18 +134,23 @@ function stackview_get_file_areas($course, $cm, $context) { * @return false|void * @throws coding_exception */ -function stackview_pluginfile(object $course, object $cm, $context, $filearea, $args, $forcedownload, - array $options = []) { - - if ($context->contextlevel != CONTEXT_MODULE) { +function stackview_pluginfile( + object $course, + object $cm, + $context, + $filearea, + $args, + $forcedownload, + array $options = [] +) { + + if ($context->contextlevel !== CONTEXT_MODULE) { return false; } - if (!has_capability('mod/stackview:view', $context)) { - return false; - } + require_course_login($course, true, $cm); - if (!is_enrolled($context) && !has_capability('moodle/site:config' , context_system::instance())) { + if (!has_capability('mod/stackview:view', $context)) { return false; } @@ -186,9 +191,13 @@ function stackview_extend_settings_navigation(settings_navigation $settings, nav if (has_capability('mod/stackview:management', $PAGE->cm->context)) { $url = new moodle_url('/mod/stackview/management.php', ['cmid' => $PAGE->cm->id]); - $node = navigation_node::create(get_string('btn:management', 'stackview'), + $node = navigation_node::create( + get_string('btn:management', 'stackview'), new moodle_url($url), - navigation_node::TYPE_SETTING, null, 'mod_stackview_management'); + navigation_node::TYPE_SETTING, + null, + 'mod_stackview_management' + ); $stacknode->add_node($node, $beforekey); } diff --git a/version.php b/version.php index 751038b..4f003ad 100644 --- a/version.php +++ b/version.php @@ -28,6 +28,6 @@ $plugin->component = 'mod_stackview'; $plugin->release = '3.9.7'; -$plugin->version = 2022090600; +$plugin->version = 2024010200; $plugin->requires = 2018051700; $plugin->maturity = MATURITY_STABLE;