From 8ab35a15eec6f1da7eb56e90e5404cc342771fba Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Tue, 28 Mar 2023 17:26:51 +0000 Subject: [PATCH] prevent warning, fixes #2436 Closes #2436 Merge request studip/studip!1631 --- lib/navigation/CourseNavigation.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/navigation/CourseNavigation.php b/lib/navigation/CourseNavigation.php index 9992095a2f1..2ff62ad8058 100644 --- a/lib/navigation/CourseNavigation.php +++ b/lib/navigation/CourseNavigation.php @@ -48,11 +48,16 @@ class CourseNavigation extends Navigation { parent::initSubNavigation(); - foreach (Context::get()->tools as $tool) { - if (Context::isInstitute() || Seminar_Perm::get()->have_studip_perm($tool->getVisibilityPermission(), Context::get()->getId())) { + $context = Context::get(); + if (!$context) { + return; + } + + foreach ($context->tools as $tool) { + if (Context::isInstitute() || Seminar_Perm::get()->have_studip_perm($tool->getVisibilityPermission(), $context->id)) { $studip_module = $tool->getStudipModule(); if ($studip_module instanceof StudipModule) { - $tool_nav = $studip_module->getTabNavigation(Context::getId()) ?: []; + $tool_nav = $studip_module->getTabNavigation($context->id) ?: []; foreach ($tool_nav as $nav_name => $navigation) { if ($nav_name && is_a($navigation, "Navigation")) { if ($tool->metadata['displayname']) { -- GitLab