From 24808b3e8e14dd5ae0230f1d376d86232d3537eb Mon Sep 17 00:00:00 2001
From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de>
Date: Mon, 11 Sep 2023 08:55:54 +0000
Subject: [PATCH] disable courseware navigation for public access, fixes #1613

Closes #1613

Merge request studip/studip!2142
---
 lib/modules/CoursewareModule.class.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/modules/CoursewareModule.class.php b/lib/modules/CoursewareModule.class.php
index 9de221f0c22..6766f8ce387 100644
--- a/lib/modules/CoursewareModule.class.php
+++ b/lib/modules/CoursewareModule.class.php
@@ -46,6 +46,10 @@ class CoursewareModule extends CorePlugin implements SystemPlugin, StudipModule
      */
     public function getTabNavigation($courseId)
     {
+        if ($GLOBALS['user']->id === 'nobody') {
+            return [];
+        }
+
         $navigation = new Navigation(
             _('Courseware'),
             URLHelper::getURL('dispatch.php/course/courseware/?cid='.$courseId)
@@ -80,6 +84,10 @@ class CoursewareModule extends CorePlugin implements SystemPlugin, StudipModule
      */
     public function getIconNavigation($courseId, $last_visit, $user_id)
     {
+        if ($user_id === 'nobody') {
+            return null;
+        }
+
         $statement = DBManager::get()->prepare("
                 SELECT COUNT(DISTINCT elem.id)
                 FROM `cw_structural_elements` AS elem
-- 
GitLab