From 666b1ca0bae7f71c19f01988c17615cf63d6e59b Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Tue, 31 May 2022 18:39:21 +0200
Subject: [PATCH 1/9] fixed PHP8 warnings in MVV area

---
 app/controllers/module/mvv_controller.php     |  4 +-
 .../studiengaenge/fachbereiche.php            | 20 +++++-----
 .../studiengaenge/shared_version.php          | 10 ++---
 .../studiengaenge/studiengaenge.php           | 11 +++---
 app/controllers/studiengaenge/versionen.php   | 24 +++++++-----
 .../studiengaenge/studiengaenge.php           |  2 +-
 .../studiengaenge/studiengangteile/index.php  |  2 +-
 .../studiengaenge/versionen/abschnitte.php    |  2 +-
 .../versionen/details_abschnitt.php           |  2 +-
 .../studiengaenge/versionen/versionen.php     |  2 +-
 lib/classes/MvvPerm.php                       | 39 +++++++++++++------
 11 files changed, 70 insertions(+), 48 deletions(-)

diff --git a/app/controllers/module/mvv_controller.php b/app/controllers/module/mvv_controller.php
index f54d8cf0645..6db19d7e9e9 100644
--- a/app/controllers/module/mvv_controller.php
+++ b/app/controllers/module/mvv_controller.php
@@ -204,7 +204,7 @@ abstract class MVVController extends AuthenticatedController
                     0, -10)) . '/';
         }
         $to = $this->url_for($to);
-        list($url, $query) = explode('?', $to);
+        $url = explode('?', $to)[0];
         $url      = URLHelper::getUrl($url, $params, true);
         $template = $this->get_template_factory()->open('shared/js_url');
         $template->set_attributes(['url' => $url]);
@@ -308,7 +308,7 @@ abstract class MVVController extends AuthenticatedController
                 }
             } else {
                 $search_term = $search_term ?: $this->search_term;
-                $filter      = $filter ?: $this->filter;
+                $filter      = $filter ?? [];
                 if ($search_term) {
                     $this->search_result =
                         $class_name::findBySearchTerm($search_term, $filter)->pluck('id');
diff --git a/app/controllers/studiengaenge/fachbereiche.php b/app/controllers/studiengaenge/fachbereiche.php
index e1f6d6df9c3..970c8d984de 100644
--- a/app/controllers/studiengaenge/fachbereiche.php
+++ b/app/controllers/studiengaenge/fachbereiche.php
@@ -17,10 +17,12 @@ class Studiengaenge_FachbereicheController extends Studiengaenge_StudiengaengeCo
     public function index_action($studiengang_id = null)
     {
         PageLayout::setTitle(_('Studiengänge gruppiert nach Fachbereichen'));
-        
+
         // Nur Fachbereiche an denen der User eine Rolle hat
         $perm_institutes = MvvPerm::getOwnInstitutes();
-        
+
+        $this->fachbereich_id = '';
+
         $this->initPageParams('fachbereiche');
         $this->sortby = $this->sortby ?: 'name';
         $this->order = $this->order ?: 'ASC';
@@ -29,7 +31,7 @@ class Studiengaenge_FachbereicheController extends Studiengaenge_StudiengaengeCo
             $this->order,
             ['Institute.Institut_id' => $perm_institutes]
         );
-        
+
         if ($studiengang_id) {
             $studiengang = Studiengang::find($studiengang_id);
             $this->details_action($studiengang->institut_id, $studiengang->id);
@@ -37,10 +39,10 @@ class Studiengaenge_FachbereicheController extends Studiengaenge_StudiengaengeCo
 
         $this->setSidebar();
     }
-    
+
     /**
      * shows the studiengaenge of a fachbereich
-     * 
+     *
      * @param string $fachbereich_id the id of the fachbereich
      */
     public function details_action($fachbereich_id, $studiengang_id = null, $stgteil_bez_id = null)
@@ -52,16 +54,16 @@ class Studiengaenge_FachbereicheController extends Studiengaenge_StudiengaengeCo
                 throw new Trails_Exception(403);
             }
         }
-        
+
         $this->parent_id = $this->fachbereich_id;
         $this->studiengaenge = Studiengang::findByFachbereich($this->fachbereich_id);
         if ($studiengang_id) {
             $this->studiengang_id = $studiengang_id;
             $this->set_studiengangteile($studiengang_id, $stgteil_bez_id);
         }
-        
+
         if (Request::isXhr()) {
-            if ($this->studiengang) {
+            if (!empty($this->studiengang)) {
                 if ($this->studiengang->typ == 'einfach') {
                     $this->render_template('studiengaenge/studiengaenge/studiengangteile');
                 } else {
@@ -78,4 +80,4 @@ class Studiengaenge_FachbereicheController extends Studiengaenge_StudiengaengeCo
             $this->perform_relayed('index');
         }
     }
-}
\ No newline at end of file
+}
diff --git a/app/controllers/studiengaenge/shared_version.php b/app/controllers/studiengaenge/shared_version.php
index 81790275236..91869ca28e5 100644
--- a/app/controllers/studiengaenge/shared_version.php
+++ b/app/controllers/studiengaenge/shared_version.php
@@ -308,8 +308,7 @@ abstract class SharedVersionController extends MVVController
         $this->version = StgteilVersion::find($version_id);
 
         // search for modules so status of version doesn't matter
-        $filter = $this->filter;
-        unset($filter['mvv_stgteilversion.stat']);
+        $filter = [];
 
         $condition = ModuleManagementModel::getFilterSql($filter);
         $query = "SELECT mvv_modul.modul_id,
@@ -681,18 +680,17 @@ abstract class SharedVersionController extends MVVController
             return;
         }
         $this->abschnitt_id = $this->abschnitt->id;
-        if(!$this->version) {
+        if(empty($this->version)) {
             $this->version = $this->abschnitt->getVersion();
         }
         $this->version_id = $this->version->getId();
         $this->assignments = StgteilabschnittModul::findByStgteilAbschnitt(
             $this->abschnitt->getId(),
-            $this->filter
+            []
         );
 
         // search for modules so status of version doesn't matter
-        $filter = $this->filter;
-        unset($filter['mvv_stgteilversion.stat']);
+        $filter = [];
         $query = "
             SELECT mvv_modul.modul_id, CONCAT(mvv_modul_deskriptor.bezeichnung, ', ',
                 IF(ISNULL(mvv_modul.code), '', mvv_modul.code),
diff --git a/app/controllers/studiengaenge/studiengaenge.php b/app/controllers/studiengaenge/studiengaenge.php
index 71790447207..4c0bca8e063 100644
--- a/app/controllers/studiengaenge/studiengaenge.php
+++ b/app/controllers/studiengaenge/studiengaenge.php
@@ -357,6 +357,7 @@ class Studiengaenge_StudiengaengeController extends MVVController
     {
         $this->set_details_studiengang($studiengang_id);
         $this->stgteil_bez_id = $stgteil_bez_id;
+        $this->stg_bez = null;
         $this->add_stgteil();
         if ($stgteil_bez_id) {
             $this->stg_bez = StgteilBezeichnung::find($stgteil_bez_id);
@@ -1047,7 +1048,7 @@ class Studiengaenge_StudiengaengeController extends MVVController
         $template_factory = $this->get_template_factory();
         $studiengang_ids = Studiengang::findByFilter($this->filter);
 
-        if ($this->search_result['Studiengang']) {
+        if (!empty($this->search_result['Studiengang'])) {
             $studiengang_ids = array_intersect($studiengang_ids, $this->search_result['Studiengang']);
         }
 
@@ -1060,18 +1061,18 @@ class Studiengaenge_StudiengaengeController extends MVVController
             'selected_semester'    => $semesters->findOneBy('beginn', $this->filter['start_sem.beginn'])->id,
             'default_semester'     => Semester::findCurrent()->id,
             'status'               => Studiengang::findStatusByIds($studiengang_ids),
-            'selected_status'      => $this->filter['mvv_studiengang.stat'],
+            'selected_status'      => $this->filter['mvv_studiengang.stat'] ?? '',
             'status_array'         => $GLOBALS['MVV_STUDIENGANG']['STATUS']['values'],
             'kategorien'           => AbschlussKategorie::findByStudiengaenge($studiengang_ids),
-            'selected_kategorie'   => $this->filter['mvv_abschl_zuord.kategorie_id'],
+            'selected_kategorie'   => $this->filter['mvv_abschl_zuord.kategorie_id'] ?? '',
             'abschluesse'          => Abschluss::findByStudiengaenge($studiengang_ids),
-            'selected_abschluss'   => $this->filter['abschluss.abschluss_id'],
+            'selected_abschluss'   => $this->filter['abschluss.abschluss_id'] ?? '',
             'institute'            => Studiengang::getAllAssignedInstitutes([
                 'mvv_studiengang.studiengang_id' => $studiengang_ids,
             ]),
             'selected_institut'    => $this->filter['mvv_studiengang.institut_id'],
             'fachbereiche'         => Fach::getAllAssignedInstitutes($studiengang_ids),
-            'selected_fachbereich' => $this->filter['mvv_fach_inst.institut_id'],
+            'selected_fachbereich' => $this->filter['mvv_fach_inst.institut_id'] ?? '',
             'action'               => $this->action_url('set_filter'),
             'action_reset'         => $this->action_url('reset_filter')
         ]);
diff --git a/app/controllers/studiengaenge/versionen.php b/app/controllers/studiengaenge/versionen.php
index 6868ee5cfc5..13de55b24e6 100644
--- a/app/controllers/studiengaenge/versionen.php
+++ b/app/controllers/studiengaenge/versionen.php
@@ -82,12 +82,15 @@ class Studiengaenge_VersionenController extends SharedVersionController
 
     protected function chooser_faecher_fachbereich()
     {
-        $faecher = Fach::findByFachbereich($this->chooser_filter['fachbereich'], true);
+        $faecher = [];
+        if (!empty($this->chooser_filter['fachbereich'])) {
+            $faecher = Fach::findByFachbereich($this->chooser_filter['fachbereich'], true);
+        }
         foreach ($faecher as $fach) {
             $this->lists['faecher_fachbereich']['elements'][$fach->id] = ['name' => $fach->name];
         }
         $this->lists['faecher_fachbereich']['headline'] = _('Fach');
-        $this->lists['faecher_fachbereich']['selected'] = $this->chooser_filter['fach'];
+        $this->lists['faecher_fachbereich']['selected'] = $this->chooser_filter['fach'] ?? '';
     }
 
     protected function chooser_studiengaenge_kategorie()
@@ -148,9 +151,12 @@ class Studiengaenge_VersionenController extends SharedVersionController
 
     protected function chooser_stgteile_fach()
     {
-        $stgteile = StudiengangTeil::findByFach(
-            $this->chooser_filter['fach'], null, 'zusatz,kp', 'ASC'
-        );
+        $stgteile = [];
+        if (!empty($this->chooser_filter['fach'])) {
+            $stgteile = StudiengangTeil::findByFach(
+                $this->chooser_filter['fach'], null, 'zusatz,kp', 'ASC'
+            );
+        }
         foreach ($stgteile as $stgteil) {
             $this->lists['stgteile_fach']['elements'][$stgteil->id] = [
                 'name' => $stgteil->getDisplayName()
@@ -158,7 +164,7 @@ class Studiengaenge_VersionenController extends SharedVersionController
         }
         $this->lists['stgteile_fach']['headline'] = _('Studiengangteil');
         $this->lists['stgteile_fach']['stop'] = 1;
-        $this->lists['stgteile_fach']['selected'] = $this->chooser_filter['stgteil'];
+        $this->lists['stgteile_fach']['selected'] = $this->chooser_filter['stgteil'] ?? '';
     }
 
     protected function chooser_index()
@@ -169,7 +175,7 @@ class Studiengaenge_VersionenController extends SharedVersionController
             $this->lists['index']['elements'][$key] = ['name' => $fachbereich['name']];
         }
         $this->lists['index']['headline'] = _('Fachbereich');
-        $this->lists['index']['selected'] = $this->chooser_filter['fachbereich'];
+        $this->lists['index']['selected'] = $this->chooser_filter['fachbereich'] ?? '';
     }
 
     /**
@@ -203,7 +209,7 @@ class Studiengaenge_VersionenController extends SharedVersionController
 
     public function index_action($stgteil_id = null)
     {
-        $stgteil_id = Request::option('id', $stgteil_id ?: $this->chooser_filter['stgteil']);
+        $stgteil_id = Request::option('id', $stgteil_id ?? $this->chooser_filter['stgteil'] ?? '');
         PageLayout::setTitle(_('Versionen des gewählten Studiengangteils'));
         if ($stgteil_id) {
             $this->stgteil = StudiengangTeil::find($stgteil_id);
@@ -275,7 +281,7 @@ class Studiengaenge_VersionenController extends SharedVersionController
             $this->action_url('reset'),
             Icon::create('refresh')
         );
-        if ($this->chooser_filter['stgteil']) {
+        if (!empty($this->chooser_filter['stgteil'])) {
             $stgteil = StudiengangTeil::find($this->chooser_filter['stgteil']);
             if ($stgteil && MvvPerm::haveFieldPermVersionen($stgteil, MvvPerm::PERM_CREATE)) {
                 $widget->addLink(
diff --git a/app/views/studiengaenge/studiengaenge/studiengaenge.php b/app/views/studiengaenge/studiengaenge/studiengaenge.php
index 57021c17b87..ad677ed9a54 100644
--- a/app/views/studiengaenge/studiengaenge/studiengaenge.php
+++ b/app/views/studiengaenge/studiengaenge/studiengaenge.php
@@ -85,7 +85,7 @@
                 </form>
             </td>
         </tr>
-        <? if ($studiengang_id === $studiengang->id) : ?>
+        <? if (!empty($studiengang_id) && ($studiengang_id === $studiengang->id)) : ?>
             <? if ($studiengang->typ == 'mehrfach') : ?>
                 <tr class="loaded-details nohover">
                     <?= $this->render_partial('studiengaenge/studiengaenge/stgteil_bezeichnungen', compact('studiengang_id', 'studiengang', 'bez_stgteile', 'stgteile', 'stg_stgbez_id', 'search_stgteil', 'search')) ?>
diff --git a/app/views/studiengaenge/studiengangteile/index.php b/app/views/studiengaenge/studiengangteile/index.php
index 6778c7b320c..8c50c4cd6dc 100644
--- a/app/views/studiengaenge/studiengangteile/index.php
+++ b/app/views/studiengaenge/studiengangteile/index.php
@@ -84,7 +84,7 @@
                             <?= $actionMenu->render() ?>
                         </td>
                     </tr>
-                    <? if ($stgteil_id == $stgteil->getId()) : ?>
+                    <? if (!empty($stgteil_id) && ($stgteil_id == $stgteil->getId())) : ?>
                         <? $versionen = StgteilVersion::findByStgteil($stgteil->getId()); ?>
                         <tr class="loaded-details nohover">
                             <?= $this->render_partial('studiengaenge/studiengangteile/details', compact('stgteil_id', 'versionen')) ?>
diff --git a/app/views/studiengaenge/versionen/abschnitte.php b/app/views/studiengaenge/versionen/abschnitte.php
index 2034bffc6e6..bad66734b78 100644
--- a/app/views/studiengaenge/versionen/abschnitte.php
+++ b/app/views/studiengaenge/versionen/abschnitte.php
@@ -53,7 +53,7 @@
                         </form>
                     </td>
                 </tr>
-                <? if ($abschnitt_id === $abschnitt->id) : ?>
+                <? if (!empty($abschnitt_id) && ($abschnitt_id === $abschnitt->id)) : ?>
                     <tr class="loaded-details nohover">
                         <?= $this->render_partial('studiengaenge/versionen/details_abschnitt', compact('abschnitt')) ?>
                     </tr>
diff --git a/app/views/studiengaenge/versionen/details_abschnitt.php b/app/views/studiengaenge/versionen/details_abschnitt.php
index 295b1399ead..843316c156b 100644
--- a/app/views/studiengaenge/versionen/details_abschnitt.php
+++ b/app/views/studiengaenge/versionen/details_abschnitt.php
@@ -53,7 +53,7 @@
                     <? endif; ?>
                     </td>
                 </tr>
-                <? if ($modul_id == $assignment->modul->id) : ?>
+                <? if (!empty($modul_id) && ($modul_id == $assignment->modul->id)) : ?>
                 <tr class="loaded-details nohover">
                     <?= $this->render_partial('studiengaenge/versionen/modulteile', ['modul' => $assignment->modul, 'abschnitt_id' => $assignment->abschnitt_id, 'assignment' => $assignment]) ?>
                 </tr>
diff --git a/app/views/studiengaenge/versionen/versionen.php b/app/views/studiengaenge/versionen/versionen.php
index 96b3470cc11..f4ad9af8fd2 100644
--- a/app/views/studiengaenge/versionen/versionen.php
+++ b/app/views/studiengaenge/versionen/versionen.php
@@ -82,7 +82,7 @@
                 </form>
             </td>
         </tr>
-        <? if ($version_id === $version->id) : ?>
+        <? if (!empty($version_id) && ($version_id === $version->id)) : ?>
             <tr class="loaded-details nohover">
                 <?= $this->render_partial('studiengaenge/versionen/abschnitte', compact('version', 'abschnitte')) ?>
             </tr>
diff --git a/lib/classes/MvvPerm.php b/lib/classes/MvvPerm.php
index 702dfd06827..e1a2410b2dd 100644
--- a/lib/classes/MvvPerm.php
+++ b/lib/classes/MvvPerm.php
@@ -86,7 +86,7 @@ class MvvPerm {
         } else {
             $index = $mvv_object;
         }
-        if (!$perm_objects[$index]) {
+        if (empty($perm_objects[$index])) {
             if (!is_object($mvv_object)) {
                 $mvv_class_name = (string) $mvv_object;
                 $mvv_object = new $mvv_class_name;
@@ -158,8 +158,12 @@ class MvvPerm {
         if (mb_strpos($name, 'haveperm') === 0) {
             $perm = 'PERM_' . mb_strtoupper(mb_substr($name, 8));
             if (defined('self::' . $perm)) {
-                return self::get($arguments[0])->havePerm(constant('self::' . $perm),
-                        $arguments[1], $arguments[2], $arguments[3]);
+                return self::get($arguments[0])->havePerm(
+                    constant('self::' . $perm),
+                    $arguments[1] ?? null,
+                    $arguments[2] ?? null,
+                    $arguments[3] ?? null
+                );
             } else {
                 throw new InvalidArgumentException('Undefined Permission.');
             }
@@ -167,14 +171,21 @@ class MvvPerm {
 
         if (mb_strpos($name, 'getfieldperm') === 0) {
             $field = mb_strtolower(mb_substr($name, 12));
-            return self::get($arguments[0])->getFieldPerm($field,
-                    $arguments[1], $arguments[2]);
+            return self::get($arguments[0])->getFieldPerm(
+                $field,
+                $arguments[1] ?? null,
+                $arguments[2] ?? null
+            );
         }
 
         if (mb_strpos($name, 'havefieldperm') === 0) {
             $field = mb_strtolower(mb_substr($name, 13));
-            return self::get($arguments[0])->haveFieldPerm($field, $arguments[1],
-                    $arguments[2], $arguments[3]);
+            return self::get($arguments[0])->haveFieldPerm(
+                $field,
+                $arguments[1] ?? null,
+                $arguments[2] ?? null,
+                $arguments[3] ?? null
+            );
         }
 
         throw new BadMethodCallException('Method '
@@ -235,8 +246,12 @@ class MvvPerm {
         if (mb_strpos($name, 'haveperm') === 0) {
             $perm = 'PERM_' . mb_strtoupper(mb_substr($name, 8));
             if (defined('self::' . $perm)) {
-                return $this->havePerm(constant('self::' . $perm),
-                        $arguments[0], $arguments[1], $arguments[2]);
+                return $this->havePerm(
+                    constant('self::' . $perm),
+                    $arguments[0] ?? null,
+                    $arguments[1] ?? null,
+                    $arguments[2] ?? null
+                );
             } else {
                 throw new InvalidArgumentException('Undefined Permission.');
             }
@@ -539,7 +554,7 @@ class MvvPerm {
      */
     public static function getRoles($user_id)
     {
-        if (!isset(self::$roles[$user_id])) {
+        if (empty(self::$roles[$user_id])) {
             self::$roles[$user_id] = array_filter(
                 RolePersistence::getAssignedRoles($user_id),
                 function ($role) {
@@ -547,7 +562,7 @@ class MvvPerm {
                 }
             );
         }
-        return self::$roles[$user_id];
+        return self::$roles[$user_id] ?? [];
     }
 
     /**
@@ -605,7 +620,7 @@ class MvvPerm {
             }
         }
 
-        if (self::$user_role_institutes[$user_id] === null) {
+        if (empty(self::$user_role_institutes[$user_id])) {
             $institutes = [];
             foreach ($roles as $role) {
 
-- 
GitLab


From da95e6ea29d8880a1c2f9d1d7937c8a44c525f9a Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Thu, 23 Jun 2022 15:56:13 +0200
Subject: [PATCH 2/9] fixed PHP8 warnings in MVV area

---
 .../studiengaenge/fachbereichestgteile.php        | 15 ++++++++-------
 app/controllers/studiengaenge/faecher.php         | 13 +++++++------
 .../studiengangteile/details_grouped.php          |  4 ++--
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/app/controllers/studiengaenge/fachbereichestgteile.php b/app/controllers/studiengaenge/fachbereichestgteile.php
index a401d50b0a4..3f8e29bf710 100644
--- a/app/controllers/studiengaenge/fachbereichestgteile.php
+++ b/app/controllers/studiengaenge/fachbereichestgteile.php
@@ -11,13 +11,14 @@ class Studiengaenge_FachbereichestgteileController extends Studiengaenge_Studien
 {
     public function index_action()
     {
+        $this->details_id = null;
         PageLayout::setTitle(_('Studiengangteile gruppiert nach Fachbereichen'));
-    
+
         $this->initPageParams();
         $this->initSearchParams();
-        
+
         $search_result = $this->getSearchResult('StudiengangTeil');
-        
+
         // Nur Studiengangteile mit zugeordnetem Fach an dessen verantwortlicher
         // Einrichtung der User eine Rolle hat
         $filter['mvv_fach_inst.institut_id'] = MvvPerm::getOwnInstitutes();
@@ -36,10 +37,10 @@ class Studiengaenge_FachbereichestgteileController extends Studiengaenge_Studien
         $this->show_sidebar_search = true;
         $this->setSidebar();
     }
-    
+
     /**
      * Shows the studiengangteile of a Fachbereich.
-     * 
+     *
      * @param string $fachbereich_id the id of the Fachbereich
      */
     public function details_fachbereich_action($fachbereich_id)
@@ -57,7 +58,7 @@ class Studiengaenge_FachbereichestgteileController extends Studiengaenge_Studien
             $this->performe_relayed('index');
         }
     }
-    
+
     public function stgteil_fachbereich_action($fachbereich_id)
     {
         $fachbereich = Institute::find($fachbereich_id);
@@ -69,4 +70,4 @@ class Studiengaenge_FachbereichestgteileController extends Studiengaenge_Studien
             throw new Trails_Exception(404);
         }
     }
-}
\ No newline at end of file
+}
diff --git a/app/controllers/studiengaenge/faecher.php b/app/controllers/studiengaenge/faecher.php
index f5bbc759702..7674dde355f 100644
--- a/app/controllers/studiengaenge/faecher.php
+++ b/app/controllers/studiengaenge/faecher.php
@@ -11,12 +11,13 @@ class Studiengaenge_FaecherController extends Studiengaenge_StudiengangteileCont
 {
     public function index_action()
     {
+        $this->details_id = null;
         PageLayout::setTitle(_('Verwaltung der Studiengangteile - Studiengangteile gruppiert nach Fächern'));
         $this->initPageParams();
         $this->initSearchParams();
-        
+
         $search_result = $this->getSearchResult('StudiengangTeil');
-        
+
         // Nur Studiengangteile mit zugeordnetem Fach an dessen verantwortlicher
         // Einrichtung der User eine Rolle hat
         $filter['mvv_fach_inst.institut_id'] = MvvPerm::getOwnInstitutes();
@@ -51,10 +52,10 @@ class Studiengaenge_FaecherController extends Studiengaenge_StudiengangteileCont
         $this->show_sidebar_search = true;
         $this->setSidebar();
     }
-    
+
     /**
      * Shows the studiengangteile of a Fach.
-     * 
+     *
      * @param string $fach_id the id of the Fach
      */
     public function details_fach_action($fach_id)
@@ -77,7 +78,7 @@ class Studiengaenge_FaecherController extends Studiengaenge_StudiengangteileCont
             $this->perform_relayed('index');
         }
     }
-    
+
     public function stgteil_fach_action($fach_id)
     {
         $fach = Fach::find($fach_id);
@@ -89,4 +90,4 @@ class Studiengaenge_FaecherController extends Studiengaenge_StudiengangteileCont
         }
         $this->perform_relayed('stgteil');
     }
-}
\ No newline at end of file
+}
diff --git a/app/views/studiengaenge/studiengangteile/details_grouped.php b/app/views/studiengaenge/studiengangteile/details_grouped.php
index 499e1b2d8df..28345c1465d 100644
--- a/app/views/studiengaenge/studiengangteile/details_grouped.php
+++ b/app/views/studiengaenge/studiengangteile/details_grouped.php
@@ -12,13 +12,13 @@
             <? foreach ($stgteile as $stgteil) : ?>
                 <tr>
                     <td>
-                        <? if ($ampel_icon) : ?>
+                        <? if (!empty($ampel_icon)) : ?>
                             <?= $ampel_icon->asImg(['title' => htmlReady($ampelstatus), 'style' => 'vertical-align: text-top;']) ?>
                         <? endif; ?>
                         <?= htmlReady($stgteil->getDisplayName()) ?>
                     </td>
                     <td class="actions" style="white-space: nowrap; width: 1%;">
-                        <? $actionMenu = ActionMenu::get()->setContext($stgteil->fach_name) ?>
+                        <? $actionMenu = ActionMenu::get()->setContext($stgteil->getDisplayName()) ?>
                         <? if (MvvPerm::havePermWrite($stgteil)) : ?>
                             <? $actionMenu->addLink(
                                 $controller->action_url('stgteil/' . $stgteil->id),
-- 
GitLab


From 80af2322b61e67960f678edbcda5ac0a37bde0b7 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Thu, 23 Jun 2022 17:34:08 +0200
Subject: [PATCH 3/9] =?UTF-8?q?fixed=20PHP8=20warnings=20in=20MVV=20"Studi?=
 =?UTF-8?q?eng=C3=A4nge"=20pages?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/controllers/module/mvv_controller.php     |  3 +++
 .../studiengaenge/stgteilbezeichnungen.php    |  1 +
 app/controllers/studiengaenge/versionen.php   | 14 +++++++-----
 app/views/shared/chooser.php                  |  4 ++--
 app/views/shared/chooser_form.php             |  8 +++----
 app/views/shared/filter.php                   | 22 +++++++++----------
 app/views/studiengaenge/versionen/index.php   |  2 +-
 7 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/app/controllers/module/mvv_controller.php b/app/controllers/module/mvv_controller.php
index 6db19d7e9e9..e84b37cd264 100644
--- a/app/controllers/module/mvv_controller.php
+++ b/app/controllers/module/mvv_controller.php
@@ -67,6 +67,9 @@ abstract class MVVController extends AuthenticatedController
     {
         parent::before_filter($action, $args);
 
+        $this->sortby = '';
+        $this->page_params_suffix = '';
+
         if (!static::IsVisible()) {
             throw new AccessDeniedException();
         }
diff --git a/app/controllers/studiengaenge/stgteilbezeichnungen.php b/app/controllers/studiengaenge/stgteilbezeichnungen.php
index 3f738760f2a..4a230699293 100644
--- a/app/controllers/studiengaenge/stgteilbezeichnungen.php
+++ b/app/controllers/studiengaenge/stgteilbezeichnungen.php
@@ -16,6 +16,7 @@ class Studiengaenge_StgteilbezeichnungenController extends MVVController
 
     public function index_action()
     {
+        $this->bezeichnung_id = '';
         PageLayout::setTitle(_('Alle Studiengangteil-Bezeichnungen'));
         $this->stgteilbezeichnungen = StgteilBezeichnung::getAllEnriched();
         $this->setSidebar();
diff --git a/app/controllers/studiengaenge/versionen.php b/app/controllers/studiengaenge/versionen.php
index 13de55b24e6..ec8cf44c00a 100644
--- a/app/controllers/studiengaenge/versionen.php
+++ b/app/controllers/studiengaenge/versionen.php
@@ -32,14 +32,14 @@ class Studiengaenge_VersionenController extends SharedVersionController
         switch ($step) {
             case 'index' :
                 $this->chooser_filter['fachbereich'] =
-                    Request::option('id', $this->chooser_filter['fachbereich']);
+                    Request::option('id', !empty($this->chooser_filter['fachbereich']));
                 $this->chooser_filter['stgteile'] = null;
                 $this->chooser_faecher_fachbereich();
                 $list = 'faecher_fachbereich';
                 break;
             case 'faecher_fachbereich' :
                 $this->chooser_filter['fach'] =
-                    Request::option('id', $this->chooser_filter['fach']);
+                    Request::option('id', !empty($this->chooser_filter['fach']));
                 $this->chooser_filter['stgteile'] = null;
                 $this->chooser_stgteile_fach();
                 $list = 'stgteile_fach';
@@ -53,11 +53,13 @@ class Studiengaenge_VersionenController extends SharedVersionController
                 throw new Trails_Exception(400);
         }
         $this->name = $list;
-        foreach ((array) $this->lists[$list]['elements'] as $key => $element) {
-            $this->list['elements'][$key]['name'] = htmlReady($element['name']);
+        if (!empty($this->lists[$list]['elements'])) {
+            foreach ((array)$this->lists[$list]['elements'] as $key => $element) {
+                $this->list['elements'][$key]['name'] = htmlReady($element['name']);
+            }
         }
         $this->list['headline'] = $this->lists[$list]['headline'];
-        if ($this->lists[$list]['stop']) {
+        if (!empty($this->lists[$list]['stop'])) {
             $this->list['stop'] = 1;
         }
         $this->sessSet('chooser_filter', $this->chooser_filter);
@@ -338,7 +340,7 @@ class Studiengaenge_VersionenController extends SharedVersionController
                 'semester'          => $semesters,
                 'selected_semester' => $semesters->findOneBy('beginn', $this->filter['start_sem.beginn'])->id,
                 'status'            => $status_results,
-                'selected_status'   => $this->filter['mvv_stgteilversion.stat'],
+                'selected_status'   => $this->filter['mvv_stgteilversion.stat'] ?? '',
                 'status_array'      => $GLOBALS['MVV_STGTEILVERSION']['STATUS']['values'],
                 'action'            => $this->action_url('set_filter'),
                 'action_reset'      => $this->action_url('reset_filter')
diff --git a/app/views/shared/chooser.php b/app/views/shared/chooser.php
index e5e1cae3b0d..a7523593e43 100644
--- a/app/views/shared/chooser.php
+++ b/app/views/shared/chooser.php
@@ -4,11 +4,11 @@
     <?= $this->render_partial('shared/chooser_form', compact('name', 'list')); ?>
 <? endforeach; ?>
 </div>
-<? if ($last) : ?>
+<? if (!empty($last)) : ?>
 <script>
     <? if (sizeof($filter)) : ?>
         jQuery('#mvv-chooser-toggle').addClass('mvv-chooser-hidden');
     <? endif; ?>
     jQuery('#mvv-chooser-toggle').fadeIn();
 </script>
-<? endif; ?>
\ No newline at end of file
+<? endif; ?>
diff --git a/app/views/shared/chooser_form.php b/app/views/shared/chooser_form.php
index bb5e47e482b..ea5ee5f1558 100644
--- a/app/views/shared/chooser_form.php
+++ b/app/views/shared/chooser_form.php
@@ -1,14 +1,14 @@
-<form action="<?= $list['stop'] ? $controller->action_link('index') : $controller->action_link('chooser'); ?>" style="width: 100%;" id="<?= htmlReady($name) ?>">
-    <? if (is_array($list['elements']) && sizeof($list['elements'])) : ?>
+<form action="<?= !empty($list['stop']) ? $controller->action_link('index') : $controller->action_link('chooser'); ?>" style="width: 100%;" id="<?= htmlReady($name) ?>">
+    <? if (!empty($list['elements']) && sizeof($list['elements'])) : ?>
     <input type="hidden" name="step" value="<?= htmlReady($name) ?>">
-    <? if ($list['stop']) : ?>
+    <? if (!empty($list['stop'])) : ?>
     <input type="hidden" name="stop" value="1">
     <? endif; ?>
     <label><?= $list['headline'] ?>
         <select name="id" style="width: 100%;">
             <option value="">-- <?= _('Bitte wählen') ?> --</option>
         <? foreach ($list['elements'] as $key => $element) : ?>
-            <option value="<?= htmlReady($key) ?>"<?= $key == $list['selected'] ? ' selected' : '' ?>>
+            <option value="<?= htmlReady($key) ?>"<?= (!empty($list['selected']) && $key == $list['selected']) ? ' selected' : '' ?>>
                 <?= htmlReady($element['name']) ?>
             </option>
         <? endforeach; ?>
diff --git a/app/views/shared/filter.php b/app/views/shared/filter.php
index e80d3d2322b..6869faf2df2 100644
--- a/app/views/shared/filter.php
+++ b/app/views/shared/filter.php
@@ -1,4 +1,4 @@
-<? if ($selected_status || $selected_kategorie || $selected_abschluss || $selected_fachbereich || $selected_zuordnung || $selected_institut || $selected_name || $selected_semester != $default_semester) : ?>
+<? if (!empty($selected_status) || !empty($selected_kategorie) || !empty($selected_abschluss) || !empty($selected_fachbereich) || !empty($selected_zuordnung) || !empty($selected_institut) || !empty($selected_name) || (!empty($selected_semester) && !empty($default_semester) && $selected_semester != $default_semester)) : ?>
 <div style="width: 100%; text-align: right;">
     <a href="<?= $action_reset ?>">
         <?= Icon::create('refresh', 'clickable', ['title' => _('Filter zurücksetzen')])->asImg(); ?>
@@ -7,16 +7,16 @@
 </div>
 <? endif; ?>
 <form id="index_filter" action="<?= $action ?>" method="post">
-    <? if ($name_search) : ?>
+    <? if (!empty($name_search)) : ?>
         <label class="mvv-name-search">
             <?= $name_caption ?: _('Name') ?>:
             <input type="text" name="name_filter" value="<?= htmlReady($selected_name) ?>">
             <input type="submit" value="<?= _('Suchen') ?>">
         </label>
     <? endif ?>
-    <? if (isset($semester)) : ?>
+    <? if (!empty($semester)) : ?>
     <label>
-        <?= $semester_caption ?: _('Semester') . ':' ?><br>
+        <?= $semester_caption ?? _('Semester') . ':' ?><br>
         <select name="semester_filter" class="sidebar-selectlist submit-upon-select">
             <option value="all"<?= (!$selected_semester ? ' selected' : '') ?>><?= _('Alle Semester') ?></option>
             <? foreach ($semester as $sem) : ?>
@@ -25,7 +25,7 @@
         </select>
     </label>
     <? endif; ?>
-    <? if (isset($zuordnungen)) : ?>
+    <? if (!empty($zuordnungen)) : ?>
     <label>
         <?= _('Zugeordnet zu Objekten') ?>:
         <select name="zuordnung_filter" class="sidebar-selectlist submit-upon-select">
@@ -37,7 +37,7 @@
         </select>
     </label>
     <? endif; ?>
-    <? if (isset($status)) : ?>
+    <? if (!empty($status)) : ?>
     <label>
         <?= _('Status') ?>:<br>
         <select name="status_filter" class="sidebar-selectlist submit-upon-select">
@@ -49,12 +49,12 @@
             <? endif; ?>
             <? endforeach; ?>
             <? if ($status['__undefined__']) : ?>
-                <option value="__undefined__"<?= $selected_status == '__undefined__' ? ' selected' : '' ?>><?= _('nicht angegeben')  . ' (' . ($stat['count_objects'] ?: '0') . ')' ?></option>
+                <option value="__undefined__"<?= $selected_status == '__undefined__' ? ' selected' : '' ?>><?= _('nicht angegeben')  . ' (' . ($stat['count_objects'] ?? '0') . ')' ?></option>
             <? endif; ?>
         </select>
     </label>
     <? endif; ?>
-    <? if (isset($kategorien)) : ?>
+    <? if (!empty($kategorien)) : ?>
     <label>
         <?= _('Kategorie') ?>:<br>
         <select name="kategorie_filter" class="sidebar-selectlist submit-upon-select">
@@ -68,7 +68,7 @@
         </select>
     </label>
     <? endif; ?>
-    <? if (isset($abschluesse)) : ?>
+    <? if (!empty($abschluesse)) : ?>
     <label>
         <?= _('Abschluss') ?>:<br>
         <select name="abschluss_filter" class="sidebar-selectlist submit-upon-select">
@@ -79,7 +79,7 @@
         </select>
     </label>
     <? endif; ?>
-    <? if (isset($institute)) : ?>
+    <? if (!empty($institute)) : ?>
         <? $perm_institutes = MvvPerm::getOwnInstitutes() ?>
         <? if ($perm_institutes !== false) : ?>
         <label>
@@ -104,7 +104,7 @@
         </label>
         <? endif ?>
     <? endif; ?>
-    <? if (isset($fachbereiche)) : ?>
+    <? if (!empty($fachbereiche)) : ?>
         <? $perm_institutes = MvvPerm::getOwnInstitutes() ?>
         <? if ($perm_institutes !== false) : ?>
         <label>
diff --git a/app/views/studiengaenge/versionen/index.php b/app/views/studiengaenge/versionen/index.php
index 7e382256c01..ebf8fb13675 100644
--- a/app/views/studiengaenge/versionen/index.php
+++ b/app/views/studiengaenge/versionen/index.php
@@ -36,7 +36,7 @@
             </tfoot>
         <? endif; ?>
     </table>
-    <? if ($stgteil && !$count) : ?>
+    <? if (!empty($stgteil) && !$count) : ?>
         <div>
             <?= sprintf(_('Für den Studiengangteil <strong>%s</strong> wurden noch keine Versionen angelegt. '), htmlReady($stgteil->getDisplayName())) ?>
         </div>
-- 
GitLab


From a494cbcb077fd3aa48727c7933b3fe7c8dce0107 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Thu, 23 Jun 2022 17:55:51 +0200
Subject: [PATCH 4/9] fixed PHP8 warnings on MVV "Module" pages

---
 app/controllers/module/institute.php         |  2 ++
 app/controllers/module/module.php            | 18 ++++++++++++------
 lib/classes/MvvPerm.php                      |  8 ++++++--
 lib/models/ModuleManagementModelTreeItem.php |  2 +-
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/app/controllers/module/institute.php b/app/controllers/module/institute.php
index 0572640a11c..5ac67fd5a6a 100644
--- a/app/controllers/module/institute.php
+++ b/app/controllers/module/institute.php
@@ -16,6 +16,8 @@ class Module_InstituteController extends Module_ModuleController
         parent::before_filter($action, $args);
         URLHelper::bindLinkParam('institut_id', $this->institut_id);
 
+        $this->inst_id = '';
+
         if (Request::isXhr()) {
             $this->set_layout(null);
         }
diff --git a/app/controllers/module/module.php b/app/controllers/module/module.php
index c936feec076..74415ba81b4 100644
--- a/app/controllers/module/module.php
+++ b/app/controllers/module/module.php
@@ -20,6 +20,9 @@ class Module_ModuleController extends MVVController
         Navigation::activateItem($this->me . '/module/module');
         $this->filter = $this->sessGet('filter', []);
         $this->action = $action;
+        $this->modul_id = '';
+        $this->details_url = '';
+        $this->modulteil_id = '';
 
         PageLayout::addSqueezePackage('statusgroups');
     }
@@ -44,7 +47,7 @@ class Module_ModuleController extends MVVController
 
         // Nur Module von verantwortlichen Einrichtungen an denen der User
         // eine Rolle hat
-        if (!$this->filter['mvv_modul_inst.institut_id']) {
+        if (empty($this->filter['mvv_modul_inst.institut_id'])) {
             unset($this->filter['mvv_modul_inst.institut_id']);
         }
         $this->filter = array_merge(
@@ -1343,7 +1346,7 @@ class Module_ModuleController extends MVVController
     {
         // Nur Module von verantwortlichen Einrichtungen an denen der User
         // eine Rolle hat
-        if (!$this->filter['mvv_modul_inst.institut_id']) {
+        if (empty($this->filter['mvv_modul_inst.institut_id'])) {
             unset($this->filter['mvv_modul_inst.institut_id']);
         }
         $modul_filter = array_merge(
@@ -1360,22 +1363,25 @@ class Module_ModuleController extends MVVController
         // Status
         $modul_ids = Modul::findByFilter($modul_filter);
         $template->set_attribute('status', Modul::findStatusByIds($modul_ids));
-        $template->set_attribute('selected_status', $this->filter['mvv_modul.stat']);
+        $template->set_attribute('selected_status', $this->filter['mvv_modul.stat'] ?? '');
         $template->set_attribute('status_array', $GLOBALS['MVV_MODUL']['STATUS']['values']);
 
         // Institutes
         $template->set_attribute('institute', Modul::getAllAssignedInstitutes('name', 'ASC', $modul_filter));
         $template->set_attribute('institute_count', 'count_objects');
-        $template->set_attribute('selected_institut', $this->filter['mvv_modul_inst.institut_id']);
+        $template->set_attribute('selected_institut', $this->filter['mvv_modul_inst.institut_id'] ?? '');
 
         // Semesters
         $semesters = new SimpleCollection(Semester::getAll());
         $semesters = $semesters->orderBy('beginn desc');
-        $selected_semester = $semesters->findOneBy('beginn', $this->filter['start_sem.beginn']);
+        $selected_semester = null;
+        if (!empty($this->filter['start_sem.beginn'])) {
+            $selected_semester = $semesters->findOneBy('beginn', $this->filter['start_sem.beginn']);
+        }
 
 
         $template->set_attribute('semester', $semesters);
-        $template->set_attribute('selected_semester', $selected_semester->id);
+        $template->set_attribute('selected_semester', $selected_semester->id ?? '');
         $template->set_attribute('default_semester', Semester::findCurrent()->id);
 
         $template->set_attribute('action', $this->set_filterURL());
diff --git a/lib/classes/MvvPerm.php b/lib/classes/MvvPerm.php
index e1a2410b2dd..ca61536fdbb 100644
--- a/lib/classes/MvvPerm.php
+++ b/lib/classes/MvvPerm.php
@@ -265,8 +265,12 @@ class MvvPerm {
 
         if (mb_strpos($name, 'havefieldperm') === 0) {
             $field = mb_strtolower(mb_substr($name, 13));
-            return $this->haveFieldPerm($field, $arguments[0],
-                    $arguments[1], $arguments[2]);
+            return $this->haveFieldPerm(
+                $field,
+                $arguments[0],
+                $arguments[1] ?? null,
+                $arguments[2] ?? null
+            );
         }
 
         throw new BadMethodCallException('Method '
diff --git a/lib/models/ModuleManagementModelTreeItem.php b/lib/models/ModuleManagementModelTreeItem.php
index 1c4a6deb6d1..c2d4269c32b 100644
--- a/lib/models/ModuleManagementModelTreeItem.php
+++ b/lib/models/ModuleManagementModelTreeItem.php
@@ -95,7 +95,7 @@ abstract class ModuleManagementModelTreeItem extends ModuleManagementModel imple
      */
     private function checkFilter(MvvTreeItem $item)
     {
-        $filter = self::$object_filter[get_class($item)];
+        $filter = self::$object_filter[get_class($item)] ?? null;
         if ($filter && is_callable($filter)) {
             $checked = $filter($item);
             if (!$checked) {
-- 
GitLab


From 869746449c16f47a1910e1b9a205ee2dde5ef73b Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Thu, 23 Jun 2022 18:09:49 +0200
Subject: [PATCH 5/9] fixed PHP8 warnings on MVV "LV-Gruppen" pages

---
 app/controllers/lvgruppen/lvgruppen.php | 5 ++++-
 lib/models/Lvgruppe.php                 | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/controllers/lvgruppen/lvgruppen.php b/app/controllers/lvgruppen/lvgruppen.php
index 9e3e7a4902d..194f1718ba0 100644
--- a/app/controllers/lvgruppen/lvgruppen.php
+++ b/app/controllers/lvgruppen/lvgruppen.php
@@ -15,6 +15,9 @@ class Lvgruppen_LvgruppenController extends MVVController
     public function before_filter(&$action, &$args)
     {
         parent::before_filter($action, $args);
+
+        $this->lvgruppe_id = '';
+
         // set navigation
         Navigation::activateItem($this->me . '/lvgruppen/lvgruppen');
         $this->filter = $this->sessGet('filter', []);
@@ -41,7 +44,7 @@ class Lvgruppen_LvgruppenController extends MVVController
         // Nur LvGruppen an Modulen von verantwortlichen Einrichtungen an denen der User
         // eine Rolle hat
         $own_institutes = MvvPerm::getOwnInstitutes();
-        if (!$this->filter['mvv_modul_inst.institut_id']) {
+        if (empty($this->filter['mvv_modul_inst.institut_id'])) {
             $this->filter['mvv_modul_inst.institut_id'] = $own_institutes;
         } else if (count($own_institutes)) {
             $this->filter['mvv_modul_inst.institut_id'] = array_intersect(
diff --git a/lib/models/Lvgruppe.php b/lib/models/Lvgruppe.php
index 6983e01a062..3355f77de01 100644
--- a/lib/models/Lvgruppe.php
+++ b/lib/models/Lvgruppe.php
@@ -167,6 +167,8 @@ class Lvgruppe extends ModuleManagementModelTreeItem
             $filter_sql = '';
         }
         $num_args = func_num_args();
+        $semester_join = '';
+        $params = [];
         // get result filtered by a given semester
         if ($num_args == 2) {
             $semester_id = func_get_arg(1);
-- 
GitLab


From 88b1b34c33a3c4e89d34360288cbf05ca21818f9 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Mon, 10 Oct 2022 15:38:13 +0200
Subject: [PATCH 6/9] removed unnecessary code that produced PHP8 warnings

---
 app/controllers/studiengaenge/studiengaenge.php | 3 ++-
 app/views/fachabschluss/abschluesse/index.php   | 5 +----
 app/views/fachabschluss/kategorien/index.php    | 3 ---
 app/views/module/module/module.php              | 2 +-
 4 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/app/controllers/studiengaenge/studiengaenge.php b/app/controllers/studiengaenge/studiengaenge.php
index 4c0bca8e063..e0dec62f3a6 100644
--- a/app/controllers/studiengaenge/studiengaenge.php
+++ b/app/controllers/studiengaenge/studiengaenge.php
@@ -1055,10 +1055,11 @@ class Studiengaenge_StudiengaengeController extends MVVController
         // Semesters
         $semesters = new SimpleCollection(Semester::getAll());
         $semesters = $semesters->orderBy('beginn desc');
+        $selected_semester = $semesters->findOneBy('beginn', $this->filter['start_sem.beginn']);
 
         $filter_template = $template_factory->render('shared/filter', [
             'semester'             => $semesters,
-            'selected_semester'    => $semesters->findOneBy('beginn', $this->filter['start_sem.beginn'])->id,
+            'selected_semester'    => $selected_semester ? $selected_semester->id : '',
             'default_semester'     => Semester::findCurrent()->id,
             'status'               => Studiengang::findStatusByIds($studiengang_ids),
             'selected_status'      => $this->filter['mvv_studiengang.stat'] ?? '',
diff --git a/app/views/fachabschluss/abschluesse/index.php b/app/views/fachabschluss/abschluesse/index.php
index 60fac2a5913..99422ab64d5 100644
--- a/app/views/fachabschluss/abschluesse/index.php
+++ b/app/views/fachabschluss/abschluesse/index.php
@@ -48,9 +48,6 @@
             <? endif; ?>
             </td>
         </tr>
-        <? if ($abschluss_id === $abschluss->id) : ?>
-            <?= $this->render_partial('fachabschluss/abschluesse/details', compact('abschluss')) ?>
-        <? endif; ?>
         </tbody>
         <? endforeach; ?>
         <? if ($count > MVVController::$items_per_page) : ?>
@@ -67,7 +64,7 @@
                         $pagination->set_attribute('pagelink', $page_link);
                         echo $pagination->render('shared/pagechooser');
                     ?>
-                    
+
                     </td>
                 </tr>
             </tfoot>
diff --git a/app/views/fachabschluss/kategorien/index.php b/app/views/fachabschluss/kategorien/index.php
index 5eb1ada2072..7cfa6a530e3 100644
--- a/app/views/fachabschluss/kategorien/index.php
+++ b/app/views/fachabschluss/kategorien/index.php
@@ -57,9 +57,6 @@
                             <? endif; ?>
                         </td>
                     </tr>
-                    <? if ($kategorie_id === $kategorie->id) : ?>
-                        <?= $this->render_partial('fachabschluss/kategorien/details', compact('kategorie')) ?>
-                    <? endif; ?>
                 </tbody>
             <? endforeach; ?>
         <? else : ?>
diff --git a/app/views/module/module/module.php b/app/views/module/module/module.php
index 5dfe3656a39..7700a3f5895 100644
--- a/app/views/module/module/module.php
+++ b/app/views/module/module/module.php
@@ -6,7 +6,7 @@
         <tr class="header-row" id="modul_<?= $modul->getId() ?>">
             <? if ($modul->count_modulteile) : ?>
                 <td style="white-space:nowrap;" class="toggle-indicator">
-                    <? $details_action = $details_action ?: 'details'; ?>
+                    <? $details_action = $details_action ?? 'details'; ?>
                     <a class="mvv-load-in-new-row" href="<?= $controller->action_link($details_action, $modul->getId()) ?>">
                         <? if ($ampel_icon) : ?>
                             <?= $ampel_icon->asImg(['title' => $ampelstatus, 'style' => 'vertical-align: text-top;']) ?>
-- 
GitLab


From d0ff3b555c20a0a37fa880744507f9079c8d3dd3 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Mon, 10 Oct 2022 16:15:15 +0200
Subject: [PATCH 7/9] fixed more PHP8 warnings in mvv area

---
 app/controllers/materialien/files.php | 11 ++++++-----
 app/controllers/shared/contacts.php   | 18 +++++++++++-------
 app/views/shared/contacts/details.php |  2 +-
 app/views/shared/contacts/index.php   |  2 +-
 lib/models/MvvFile.php                |  4 ++--
 5 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/app/controllers/materialien/files.php b/app/controllers/materialien/files.php
index 5b35a618711..65c9b4404e3 100644
--- a/app/controllers/materialien/files.php
+++ b/app/controllers/materialien/files.php
@@ -58,6 +58,7 @@ class Materialien_FilesController extends MVVController
             }
         }
 
+        $this->range_id = '';
         if (Request::option('range_id')) {
             $this->filter = ['mvv_files.range_id' => Request::option('range_id')];
             $this->sortby = 'position';
@@ -66,7 +67,7 @@ class Materialien_FilesController extends MVVController
 
         // show only files assigned to objects where the responsible institute is
         // in the list of users own institutes
-        if (!$this->filter['mvv_studiengang.institut_id']) {
+        if (empty($this->filter['mvv_studiengang.institut_id'])) {
             $this->filter['mvv_studiengang.institut_id'] = MvvPerm::getOwnInstitutes();
         }
 
@@ -655,16 +656,16 @@ class Materialien_FilesController extends MVVController
         $semesters = new SimpleCollection(array_reverse(Semester::getAll()));
         $filter_template = $template_factory->render('shared/filter', [
             'name_search'        => true,
-            'selected_name'      => $this->filter['searchnames'],
+            'selected_name'      => $this->filter['searchnames'] ?? '',
             'name_caption'       => _('Name, Kategorie, Schlagwort'),
             'semester'           => $semesters,
             'selected_semester'  => $semesters->findOneBy('beginn', $this->filter['start_sem.beginn'])->id,
             'default_semester'   => Semester::findCurrent()->id,
             'institute'          => MvvFile::getAllAssignedInstitutes('name', 'ASC', $institute_filter),
             'institute_count'    => 'count_objects',
-            'selected_institut'  => $this->filter['mvv_studiengang.institut_id'],
-            'zuordnungen'        => MvvFile::getAllRelations($this->search_result['MvvFile']),
-            'selected_zuordnung' => $this->filter['mvv_files_ranges.range_type'],
+            'selected_institut'  => $this->filter['mvv_studiengang.institut_id'] ?? '',
+            'zuordnungen'        => !empty($this->search_result['MvvFile']) ? MvvFile::getAllRelations($this->search_result['MvvFile']) : [],
+            'selected_zuordnung' => $this->filter['mvv_files_ranges.range_type'] ?? '',
             'action'             => $this->action_url('set_filter'),
             'action_reset'       => $this->action_url('reset_filter')]
         );
diff --git a/app/controllers/shared/contacts.php b/app/controllers/shared/contacts.php
index 188ade4dc5c..fb43669a135 100644
--- a/app/controllers/shared/contacts.php
+++ b/app/controllers/shared/contacts.php
@@ -61,7 +61,7 @@ class Shared_ContactsController extends MVVController
 
         // Nur Module von verantwortlichen Einrichtungen an denen der User
         // eine Rolle hat
-        if (!$this->filter['mvv_modul_inst.institut_id']) {
+        if (empty($this->filter['mvv_modul_inst.institut_id'])) {
             unset($this->filter['mvv_modul_inst.institut_id']);
         }
         if ($search_result) {
@@ -69,7 +69,7 @@ class Shared_ContactsController extends MVVController
         }
 
         $own_institutes = MvvPerm::getOwnInstitutes();
-        if ($this->filter['mvv_modul_inst.institut_id']) {
+        if (!empty($this->filter['mvv_modul_inst.institut_id'])) {
             if ($own_institutes) {
                 $this->filter['mvv_modul_inst.institut_id']  = array_intersect(
                         $this->filter['mvv_modul_inst.institut_id'],
@@ -353,13 +353,17 @@ class Shared_ContactsController extends MVVController
             'default_semester'   => Semester::findCurrent()->id,
             'institute'          => MvvContact::getAllAssignedInstitutes('name', 'ASC', $institute_filter),
             'institute_count'    => 'count_objects',
-            'selected_institut'  => $this->filter['mvv_modul_inst.institut_id'],
-            'zuordnungen'        => MvvContact::getAllRelations($this->search_result['MvvContact']),
-            'selected_zuordnung' => $this->filter['mvv_contacts_ranges.range_type'],
+            'selected_institut'  => $this->filter['mvv_modul_inst.institut_id'] ?? '',
+            'zuordnungen'        => !empty($this->search_result['MvvContact']) ? MvvContact::getAllRelations($this->search_result['MvvContact']) : [],
+            'selected_zuordnung' => $this->filter['mvv_contacts_ranges.range_type'] ?? '',
             'kategorien'         => $this->findCategoriesByIds(),
-            'selected_kategorie' => "{$this->filter['mvv_contacts_ranges.category']}__@type__{$this->filter['mvv_contacts_ranges.range_type']}",
+            'selected_kategorie' => sprintf(
+                "%s__@type__%s",
+                $this->filter['mvv_contacts_ranges.category'] ?? '',
+                $this->filter['mvv_contacts_ranges.range_type'] ?? ''
+            ),
             'status'             => $this->findStatusByIds(),
-            'selected_status'    => $this->filter['mvv_contacts.contact_status'],
+            'selected_status'    => $this->filter['mvv_contacts.contact_status'] ?? '',
             'status_array'       => ['intern' => ['name' => _('Intern')], 'extern' => ['name' =>_('Extern')]],
             'action'             => $this->action_url('set_filter'),
             'action_reset'       => $this->action_url('reset_filter')
diff --git a/app/views/shared/contacts/details.php b/app/views/shared/contacts/details.php
index 680ccee3f53..f39d2001e51 100644
--- a/app/views/shared/contacts/details.php
+++ b/app/views/shared/contacts/details.php
@@ -4,7 +4,7 @@
     <? else : ?>
         <? $object_types = ['Studiengang', 'StudiengangTeil', 'Modul'] ?>
         <? foreach ($object_types as $object_type) : ?>
-            <? $object_relations = $relations[$object_type] ?>
+            <? $object_relations = $relations[$object_type] ?? [] ?>
             <? if (!is_array($object_relations) || count($object_relations) === 0) : continue; endif; ?>
             <table class="default sortable-table" style="margin-top: 10px;" data-sortlist="[[0, 0]]">
                 <colgroup>
diff --git a/app/views/shared/contacts/index.php b/app/views/shared/contacts/index.php
index 2d18dc7c7af..60735740733 100644
--- a/app/views/shared/contacts/index.php
+++ b/app/views/shared/contacts/index.php
@@ -28,7 +28,7 @@
                     href="<?= $controller->url_for('shared/contacts/details/index', $mvv_contact->contact_id) ?>"><?= htmlReady($mvv_contact->getContactName()) ?></a>
             </td>
             <td class="dont-hide"><?= htmlReady($mvv_contact->alt_mail); ?></td>
-            <td class="dont-hide"><?= htmlReady($GLOBALS['MVV_CONTACTS']['STATUS']['values'][$mvv_contact->contact_status]['name']); ?></td>
+            <td class="dont-hide"><?= htmlReady($GLOBALS['MVV_CONTACTS']['STATUS']['values'][$mvv_contact->contact_status]['name'] ?? '') ?></td>
             <td class="dont-hide"><?= htmlReady($mvv_contact->count_relations); ?></td>
             <td class="dont-hide actions">
             <?
diff --git a/lib/models/MvvFile.php b/lib/models/MvvFile.php
index 493fd0351fa..109ac2b6e4f 100644
--- a/lib/models/MvvFile.php
+++ b/lib/models/MvvFile.php
@@ -178,7 +178,7 @@ class MvvFile extends ModuleManagementModel
         $parameters = [];
 
         $name_filter_sql = '';
-        if ($filter['searchnames']) {
+        if (!empty($filter['searchnames'])) {
             $name_filter_sql = " AND CONCAT_WS(' ', `file_refs`.`name`, `mvv_files_filerefs`.`name`, `mvv_files`.`category`,`mvv_files`.`tags`) LIKE :needle";
             $parameters[':needle'] = "%{$filter['searchnames']}%";
         }
@@ -297,7 +297,7 @@ class MvvFile extends ModuleManagementModel
         if (empty($filter)) {
             return parent::getCount();
         }
-        $searchnames = $filter['searchnames'];
+        $searchnames = $filter['searchnames'] ?? '';
         $name_filter_sql = '';
         if ($searchnames) {
             $name_filter_sql = " AND CONCAT_WS(' ', `file_refs`.`name`, `mvv_files_filerefs`.`name`, `mvv_files`.`category`,`mvv_files`.`tags`) LIKE ". DBManager::get()->quote('%' . $searchnames . '%');
-- 
GitLab


From f578a55954060d575be20153ee6c1e7d5c742523 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Mon, 10 Oct 2022 16:29:10 +0200
Subject: [PATCH 8/9] fixed mvv php8 warnings

---
 app/views/module/module/modul.php        | 2 +-
 lib/models/DatafieldEntryModel.class.php | 5 ++++-
 lib/models/Modul.php                     | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/app/views/module/module/modul.php b/app/views/module/module/modul.php
index b2a9e7245e3..2fa0cdd9961 100644
--- a/app/views/module/module/modul.php
+++ b/app/views/module/module/modul.php
@@ -65,7 +65,7 @@ if ($GLOBALS['MVV_MODUL']['SPRACHE']['default'] != $display_language) {
                 <? endif; ?>
                 <ul id="modul_target" class="mvv-assigned-items mvv-assign-single mvv-modul">
                     <li class="mvv-item-list-placeholder"<?= ($modul->modul_variante ? ' style="display: none;"' : '') ?>><?= _('Dieses Modul ist nicht die Variante eines anderen Moduls.') ?></li>
-                    <? if ($modul->modul_variante->id) : ?>
+                    <? if (!empty($modul->modul_variante->id)) : ?>
                         <li id="modul_<?= $modul->modul_variante->id ?>">
                             <div class="mvv-item-list-text">
                                 <?= htmlReady($modul->modul_variante->getDisplayName()) ?>
diff --git a/lib/models/DatafieldEntryModel.class.php b/lib/models/DatafieldEntryModel.class.php
index 2ea16f619ca..6bc851d77eb 100644
--- a/lib/models/DatafieldEntryModel.class.php
+++ b/lib/models/DatafieldEntryModel.class.php
@@ -78,7 +78,10 @@ class DatafieldEntryModel extends SimpleORMap implements PrivacyObject
             $range_id = $model->user_id;
             $sec_range_id = $model->institut_id;
         } elseif (is_a($model, 'ModulDeskriptor')) {
-            $params[':institution_ids'] = [$model->modul->responsible_institute->institut_id];
+            $params[':institution_ids'] = '';
+            if (!empty($model->modul->responsible_institute->institut_id)) {
+                $params[':institution_ids'] = [$model->modul->responsible_institute->institut_id];
+            }
             $object_class = $model->getVariant();
             $object_type = 'moduldeskriptor';
             $range_id = $model->deskriptor_id;
diff --git a/lib/models/Modul.php b/lib/models/Modul.php
index 8b25c788a12..a3d7d9c31a5 100644
--- a/lib/models/Modul.php
+++ b/lib/models/Modul.php
@@ -397,7 +397,7 @@ class Modul extends ModuleManagementModelTreeItem
         if (!$institute) {
             return false;
         }
-        if ($this->responsible_institute->institut_id != $institut_id) {
+        if ($this->responsible_institute && $this->responsible_institute->institut_id != $institut_id) {
             $this->responsible_institute && $this->responsible_institute->delete();
             $resp_institute = new ModulInst();
             $resp_institute->institut_id = $institute->id;
-- 
GitLab


From 7cf8b05009c2c08bf266578e664e8d9ba448fdcc Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 11 Oct 2022 08:04:06 +0000
Subject: [PATCH 9/9] small improvements

---
 lib/classes/MvvPerm.php | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/lib/classes/MvvPerm.php b/lib/classes/MvvPerm.php
index ca61536fdbb..93f9f440420 100644
--- a/lib/classes/MvvPerm.php
+++ b/lib/classes/MvvPerm.php
@@ -160,9 +160,7 @@ class MvvPerm {
             if (defined('self::' . $perm)) {
                 return self::get($arguments[0])->havePerm(
                     constant('self::' . $perm),
-                    $arguments[1] ?? null,
-                    $arguments[2] ?? null,
-                    $arguments[3] ?? null
+                    ...array_slice($arguments, 1)
                 );
             } else {
                 throw new InvalidArgumentException('Undefined Permission.');
@@ -173,8 +171,7 @@ class MvvPerm {
             $field = mb_strtolower(mb_substr($name, 12));
             return self::get($arguments[0])->getFieldPerm(
                 $field,
-                $arguments[1] ?? null,
-                $arguments[2] ?? null
+                ...array_slice($arguments, 1)
             );
         }
 
@@ -182,9 +179,7 @@ class MvvPerm {
             $field = mb_strtolower(mb_substr($name, 13));
             return self::get($arguments[0])->haveFieldPerm(
                 $field,
-                $arguments[1] ?? null,
-                $arguments[2] ?? null,
-                $arguments[3] ?? null
+                ...array_slice($arguments, 1)
             );
         }
 
@@ -248,9 +243,7 @@ class MvvPerm {
             if (defined('self::' . $perm)) {
                 return $this->havePerm(
                     constant('self::' . $perm),
-                    $arguments[0] ?? null,
-                    $arguments[1] ?? null,
-                    $arguments[2] ?? null
+                    ...$arguments
                 );
             } else {
                 throw new InvalidArgumentException('Undefined Permission.');
@@ -265,12 +258,7 @@ class MvvPerm {
 
         if (mb_strpos($name, 'havefieldperm') === 0) {
             $field = mb_strtolower(mb_substr($name, 13));
-            return $this->haveFieldPerm(
-                $field,
-                $arguments[0],
-                $arguments[1] ?? null,
-                $arguments[2] ?? null
-            );
+            return $this->haveFieldPerm($field, ...$arguments);
         }
 
         throw new BadMethodCallException('Method '
@@ -558,7 +546,7 @@ class MvvPerm {
      */
     public static function getRoles($user_id)
     {
-        if (empty(self::$roles[$user_id])) {
+        if (!isset(self::$roles[$user_id])) {
             self::$roles[$user_id] = array_filter(
                 RolePersistence::getAssignedRoles($user_id),
                 function ($role) {
@@ -566,7 +554,7 @@ class MvvPerm {
                 }
             );
         }
-        return self::$roles[$user_id] ?? [];
+        return self::$roles[$user_id];
     }
 
     /**
@@ -624,7 +612,7 @@ class MvvPerm {
             }
         }
 
-        if (empty(self::$user_role_institutes[$user_id])) {
+        if (!isset(self::$user_role_institutes[$user_id])) {
             $institutes = [];
             foreach ($roles as $role) {
 
-- 
GitLab