Skip to content

Commit

Permalink
Merge branch '86bwm96x4-file-access' into 'master'
Browse files Browse the repository at this point in the history
Update #1 less strict access check for files, use same logic as mod_book

See merge request technisch-team/moodlefreak/mod_stackview!3
  • Loading branch information
luukverhoeven committed Feb 8, 2024
2 parents 74c6aa9 + f8b2155 commit 19a3611
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
31 changes: 20 additions & 11 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 19a3611

Please sign in to comment.