From 9c2549b86bc8b29c864832d75bc2acf75b9a7def Mon Sep 17 00:00:00 2001
From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de>
Date: Fri, 13 Sep 2024 17:23:45 +0200
Subject: [PATCH] fix warnings on PHP 8

---
 models/StudyCourseModel.php       | 10 +++++++---
 plugin.manifest                   |  2 +-
 views/admin/_addressee_lookup.php |  4 ++--
 views/admin/compose.php           |  4 ++--
 views/admin/index.php             |  2 +-
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/models/StudyCourseModel.php b/models/StudyCourseModel.php
index 7fc08f7..267766a 100644
--- a/models/StudyCourseModel.php
+++ b/models/StudyCourseModel.php
@@ -54,7 +54,9 @@ class StudycourseModel
             $studycourses = DBManager::get()->query($query1)->fetchAll(PDO::FETCH_ASSOC);
             $users = DBManager::get()->query($query2)->fetchGrouped(PDO::FETCH_COLUMN);
             foreach ($studycourses as $index => $course) {
-                $studycourses[$index]['count_user'] = $users[$course['studiengang_id']];
+                if (isset($users[$course['studiengang_id']])) {
+                    $studycourses[$index]['count_user'] = $users[$course['studiengang_id']];
+                }
             }
         }
 
@@ -69,7 +71,7 @@ class StudycourseModel
 
         foreach ($studycourses as $index => $row) {
             // get one profession with all degrees
-            $statement->execute(array($row['studiengang_id,']));
+            $statement->execute(array($row['studiengang_id']));
             $studycourses[$index]['degree'] = $statement->fetchAll(PDO::FETCH_ASSOC);
             $statement->closeCursor();
         }
@@ -108,7 +110,9 @@ class StudycourseModel
             $users = DBManager::get()->query($query2)->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP);
 
             foreach ($studydegrees as $index => $degree) {
-                $studydegrees[$index]['count_user'] = $users[$degree['abschluss_id']][0];
+                if (isset($users[$degree['abschluss_id']])) {
+                    $studydegrees[$index]['count_user'] = $users[$degree['abschluss_id']][0];
+                }
             }
         }
 
diff --git a/plugin.manifest b/plugin.manifest
index fb7f092..8ef380c 100644
--- a/plugin.manifest
+++ b/plugin.manifest
@@ -1,5 +1,5 @@
 pluginname=MultiMess
 pluginclassname=MultiMess
 origin=elan-ev
-version=2.5.3
+version=2.5.4
 studipMinVersion=5.3
diff --git a/views/admin/_addressee_lookup.php b/views/admin/_addressee_lookup.php
index c24948e..d89b90b 100644
--- a/views/admin/_addressee_lookup.php
+++ b/views/admin/_addressee_lookup.php
@@ -7,7 +7,7 @@ use Studip\Button, Studip\LinkButton;
     </label></br></br></br>
     <div style="clear:both" align="center">
         <div style="float:left;width:45%;">
-            <textarea id="cand_addressee" name="cand_addressee" rows="15" cols="40" wrap="virtual"><?=(is_array($addressee_list) ? join("\n", array_keys($addressee_list)): '')?></textarea>
+            <textarea id="cand_addressee" name="cand_addressee" rows="15" cols="40" wrap="virtual"><?= isset($cand_addressees) ? join("\n", array_keys($cand_addressees)): '' ?></textarea>
         </div>
         <div align="left">
             <input type="checkbox" name="perms[]" value="admin"> Administratoren<br>
@@ -30,4 +30,4 @@ use Studip\Button, Studip\LinkButton;
         <?= \Studip\Button::create(_('Suchen'), 'suchen') ?>
         <!-- </div> -->
     </div>
-</form>
\ No newline at end of file
+</form>
diff --git a/views/admin/compose.php b/views/admin/compose.php
index accc1d9..a24360c 100644
--- a/views/admin/compose.php
+++ b/views/admin/compose.php
@@ -73,7 +73,7 @@ $infobox = array('picture' => 'infobox/messages.jpg', 'content' => $infobox_cont
 </div>
 
 
-<form action="<?= PluginEngine::getLink('multimess/admin/send/') ?>" method=post>
+<form action="<?= PluginEngine::getLink('multimess/admin/send') ?>" method=post>
 <div id="compose-accordion">
     <h3>
         <?= _("Empfänger") ?>
@@ -89,7 +89,7 @@ $infobox = array('picture' => 'infobox/messages.jpg', 'content' => $infobox_cont
     </h3>
     <div class="admin-accordion-content">
         <?//=Icon::create('edit', array('id'=> 'addressee_lookup'))?>
-        <? if (count($cand_addressees) > 0) : ?>
+        <? if (!empty($cand_addressees)) : ?>
         <?=$this->render_partial("admin/_addressees", array('cand_addressees' => $cand_addressees));?>
         <? endif; ?>
      </div>
diff --git a/views/admin/index.php b/views/admin/index.php
index fa67ead..0495804 100644
--- a/views/admin/index.php
+++ b/views/admin/index.php
@@ -48,7 +48,7 @@ echo PluginEngine::getLink('multimess/admin/addressee_lookup/')
     <div class="form-group adressees">
         <label for="cand_addressee"><?php echo _('Empfänger:') ?></label>
         <textarea id="cand_addressee" name="cand_addressee"><?php
-            echo join(PHP_EOL, array_keys($addressee_list ?: array()))
+            echo join(PHP_EOL, array_keys($cand_addressees ?? array()))
         ?></textarea>
     </div>
     <div class="form-group groups">
-- 
GitLab