From 80b20d70add3caccfc6de2f89af8fc7bf80464fa Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Wed, 15 Mar 2023 09:25:21 +0000
Subject: [PATCH] prevent php8 warnings, fixes #2079

Closes #2079

Merge request studip/studip!1559
---
 lib/classes/StudipRangeTreeViewAdmin.class.php | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/classes/StudipRangeTreeViewAdmin.class.php b/lib/classes/StudipRangeTreeViewAdmin.class.php
index 777037aafbc..06209578176 100644
--- a/lib/classes/StudipRangeTreeViewAdmin.class.php
+++ b/lib/classes/StudipRangeTreeViewAdmin.class.php
@@ -501,7 +501,10 @@ class StudipRangeTreeViewAdmin extends TreeView{
     function isItemAdmin($item_id){
         $admin_ranges = $this->tree->getAdminRange($item_id);
         for ($i = 0; $i < count($admin_ranges); ++$i){
-            if ($this->tree_status[$admin_ranges[$i]] == 1){
+            if (
+                isset($this->tree_status[$admin_ranges[$i]])
+                && $this->tree_status[$admin_ranges[$i]] == 1
+            ) {
                 return true;
             }
         }
@@ -512,7 +515,10 @@ class StudipRangeTreeViewAdmin extends TreeView{
         $admin_ranges = $this->tree->getAdminRange($this->tree->tree_data[$item_id]['parent_id']);
         if (!empty($admin_ranges)) {
             for ($i = 0; $i < count($admin_ranges); ++$i) {
-                if ($this->tree_status[$admin_ranges[$i]] == 1) {
+                if (
+                    isset($this->tree_status[$admin_ranges[$i]])
+                    && $this->tree_status[$admin_ranges[$i]] == 1
+                ) {
                     return true;
                 }
             }
-- 
GitLab