From d08c3517019d9345269df0d9df2b2121dd05a98b Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Tue, 5 Apr 2022 17:42:23 +0800 Subject: [PATCH] MDL-74386 contentbank: Set the page context to frontpage Sets the page context to frontpage when viewing or editing site contenbank files. This logic was already applied in contentbank/index.php, so this change will bring consistency in the contenbanks pages when it comes to setting the page context. --- contentbank/edit.php | 6 +++++- contentbank/view.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contentbank/edit.php b/contentbank/edit.php index f208e226209..0a4b3ea8ef6 100644 --- a/contentbank/edit.php +++ b/contentbank/edit.php @@ -93,7 +93,11 @@ if ($context->contextlevel == CONTEXT_COURSECAT) { } $PAGE->set_url(new \moodle_url('/contentbank/edit.php', $values)); -$PAGE->set_context($context); +if ($context->id == \context_system::instance()->id) { + $PAGE->set_context(context_course::instance($context->id)); +} else { + $PAGE->set_context($context); +} if ($content) { $PAGE->navbar->add($content->get_name(), new \moodle_url('/contentbank/view.php', ['id' => $id])); } diff --git a/contentbank/view.php b/contentbank/view.php index 0c84708e145..6bee4909098 100644 --- a/contentbank/view.php +++ b/contentbank/view.php @@ -66,7 +66,11 @@ if ($context->contextlevel == CONTEXT_COURSECAT) { } $PAGE->set_url(new \moodle_url('/contentbank/view.php', ['id' => $id])); -$PAGE->set_context($context); +if ($context->id == \context_system::instance()->id) { + $PAGE->set_context(context_course::instance($context->id)); +} else { + $PAGE->set_context($context); +} $PAGE->navbar->add($record->name); $title .= ": ".$record->name; $PAGE->set_title($title);