From 4711c82b887a0629acf53352981f3badbbce8ba7 Mon Sep 17 00:00:00 2001 From: David Siegfried <david.siegfried@uni-vechta.de> Date: Tue, 30 Apr 2024 11:25:35 +0000 Subject: [PATCH] prevent php-warnings, fixes #4098 Closes #4098 Merge request studip/studip!2944 --- app/controllers/questionnaire.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/questionnaire.php b/app/controllers/questionnaire.php index fe2ed3aef12..6f805260300 100644 --- a/app/controllers/questionnaire.php +++ b/app/controllers/questionnaire.php @@ -48,6 +48,10 @@ class QuestionnaireController extends AuthenticatedController public function courseoverview_action() { $this->range_id = Context::getId(); + + if (!$this->range_id) { + throw new CheckObjectException(_('Sie haben kein Objekt gewählt.')); + } $this->range_type = Context::getType(); if (!$GLOBALS['perm']->have_studip_perm("tutor", $this->range_id)) { throw new AccessDeniedException("Only for logged in users."); @@ -593,8 +597,8 @@ class QuestionnaireController extends AuthenticatedController } $this->statusgruppen_ids = []; if (in_array($this->range_type, ["course", "institute"])) { - if ($GLOBALS['perm']->have_studip_perm("tutor", $this->range_id)) { - $statusgruppen = Statusgruppen::findByRange_id(Context::get()->id); + if ($this->range_id && $GLOBALS['perm']->have_studip_perm("tutor", $this->range_id)) { + $statusgruppen = Statusgruppen::findByRange_id($this->range_id); } else { $statusgruppen = Statusgruppen::findBySQL("INNER JOIN statusgruppe_user USING (statusgruppe_id) WHERE statusgruppen.range_id = ? AND statusgruppe_user.user_id = ? ", [ Context::get()->id, @@ -643,6 +647,7 @@ class QuestionnaireController extends AuthenticatedController object_set_visit($questionnaire['questionnaire_id'], 'vote'); } if (in_array($this->range_type, ["course", "institute"]) + && $this->range_id && !$GLOBALS['perm']->have_studip_perm("tutor", $this->range_id) && !($stopped_visible || count($this->questionnaire_data))) { $this->render_nothing(); -- GitLab