From ac094fbcb004c36e88a61f54f9cbd3139c05a3cb Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Wed, 6 Jul 2022 08:26:01 +0000
Subject: [PATCH] Fix miscellaneous errors, fixes #1276

Closes #1276

Merge request studip/studip!782
---
 .../steps/lvgroups/lvgroup_searchentry.php    | 26 ++++++++++---------
 composer.json                                 |  1 +
 lib/admission.inc.php                         |  2 +-
 .../templates/configure.php                   |  2 +-
 lib/classes/DbView.class.php                  |  6 ++---
 lib/classes/PageLayout.php                    |  1 -
 lib/classes/StudipArrayObject.class.php       | 10 ++++---
 lib/classes/StudipSemTreeViewSimple.class.php |  6 ++---
 .../coursewizardsteps/LVGroupsWizardStep.php  |  2 +-
 .../BASELibraryResultParser.class.php         |  6 +++--
 .../MarcxmlLibraryResultParser.class.php      |  4 ++-
 .../SRULibraryResultParser.class.php          |  6 ++---
 lib/dbviews/range_tree.view.php               |  7 ++++-
 lib/dbviews/sem_tree.view.php                 |  6 +++--
 .../ExternElementLinkInternSimple.class.php   | 11 ++++----
 .../views/ExternSemLectureTree.class.php      | 14 +++++-----
 lib/ilias_interface/IliasSoap.class.php       |  5 ++--
 lib/modules/CoreForum.class.php               |  4 +--
 18 files changed, 67 insertions(+), 52 deletions(-)

diff --git a/app/views/course/wizard/steps/lvgroups/lvgroup_searchentry.php b/app/views/course/wizard/steps/lvgroups/lvgroup_searchentry.php
index e4af01c1b94..a6715da793b 100644
--- a/app/views/course/wizard/steps/lvgroups/lvgroup_searchentry.php
+++ b/app/views/course/wizard/steps/lvgroups/lvgroup_searchentry.php
@@ -1,19 +1,21 @@
-<?
-# Lifter010: TODO
+<?php
 $_id = htmlReady(implode('_', (array) $area->getId()));
 ?>
 <li id="lvgruppe_search_<?= $_id ?>" class="<?= TextHelper::cycle('odd', 'even') ?>">
 
-<? if (!$inlist) : ?>
-   <?= Icon::create('arr_2left', 'sort')->asInput(["name" => 'assign['.$_id.']', "onclick" => "return STUDIP.MVV.CourseWizard.assignNode('".$_id."')",
-       "class" => in_array($_id,$values['studyareas']?:[])?'hidden-no-js':'']) ?>
-<? endif; ?>
-   <?/*  <span class="lvgruppe_selection_expand">*/?>
+   <?= Icon::create('arr_2left', Icon::ROLE_SORT)->asInput([
+       'name'    => "assign[{$_id}]",
+       'onclick' => "return STUDIP.MVV.CourseWizard.assignNode('{$_id}')",
+       'class'   => in_array($_id, $values['studyareas'] ?: []) ? 'hidden-no-js' : '',
+   ]) ?>
+
     <?= htmlReady($area->getDisplayName()) ?>
- 	<?= Icon::create('info', 'clickable')->asInput(["name" => 'lvgruppe_search[details]['.$_id.']',
-                "onclick" => "return STUDIP.MVV.CourseWizard.showSearchDetails('".$_id."')", "class" => '',
-                "data-id" => $_id, "data-course_id" => htmlReady($course_id)]) ?>
- <?/*
-    </span>*/?>
 
+    <?= Icon::create('info')->asInput([
+       'name'           => "lvgruppe_search[details][{$_id}]",
+       'onclick'        => "return STUDIP.MVV.CourseWizard.showSearchDetails('{$_id}')",
+       'class'          => '',
+       'data-id'        => $_id,
+       'data-course_id' => htmlReady($course_id),
+   ]) ?>
 </li>
diff --git a/composer.json b/composer.json
index a99ae27c2d3..3d4cea4f956 100644
--- a/composer.json
+++ b/composer.json
@@ -44,6 +44,7 @@
         "ext-pcre": "*",
         "ext-pdo": "*",
         "ext-mbstring": "*",
+        "ext-dom": "*",
         "opis/json-schema": "^1.0",
         "slim/psr7": "1.4",
         "slim/slim": "4.7.1",
diff --git a/lib/admission.inc.php b/lib/admission.inc.php
index 86980b7fe9c..817dbb50c21 100644
--- a/lib/admission.inc.php
+++ b/lib/admission.inc.php
@@ -50,7 +50,7 @@ require_once 'lib/dates.inc.php';
  *                                    to seminar_user. Overrides the $contingent-parameter
  * @param string   $contingent   optional studiengang_id, if no id is given, no contingent is considered
  * @param string   $log_message  optional log-message. if no log-message is given a default one is used
- * @return void
+ * @return bool
  */
 function insert_seminar_user($seminar_id, $user_id, $status, $copy_studycourse = false, $contingent = false, $log_message = false) {
 
diff --git a/lib/admissionrules/coursememberadmission/templates/configure.php b/lib/admissionrules/coursememberadmission/templates/configure.php
index 68b6312bc7a..c5d3e4efad2 100644
--- a/lib/admissionrules/coursememberadmission/templates/configure.php
+++ b/lib/admissionrules/coursememberadmission/templates/configure.php
@@ -41,7 +41,7 @@
 <div style="display:flex; align-items: flex-start; column-gap: 1em; flex-wrap: wrap">
 
     <?=
-    QuickSearch::get("mandatory_course_id", new SeminarSearch('number-name-lecturer'))
+    QuickSearch::get('mandatory_course_id', new SeminarSearch())
         ->fireJSFunctionOnSelect('addcourse')
         ->setInputStyle('flex: 0 0 40%')
         ->render();
diff --git a/lib/classes/DbView.class.php b/lib/classes/DbView.class.php
index 45d580e80ba..bcd7d0f8eb9 100644
--- a/lib/classes/DbView.class.php
+++ b/lib/classes/DbView.class.php
@@ -162,9 +162,9 @@ class DbView
     {
         foreach (self::$dbviewfiles as $view => $status) {
             if ($status === 0) {
-                include 'lib/dbviews/' . $view . '.view.php';
-                self::$dbviews += $_views;
-                unset($_views);
+                $views = include 'lib/dbviews/' . $view . '.view.php';
+                self::$dbviews += $views;
+
                 self::$dbviewfiles[$view] = 1;
             }
         }
diff --git a/lib/classes/PageLayout.php b/lib/classes/PageLayout.php
index a8f3ffac40c..ecb34b7c122 100644
--- a/lib/classes/PageLayout.php
+++ b/lib/classes/PageLayout.php
@@ -392,7 +392,6 @@ class PageLayout
         $package_elements = [];
 
         if (isset($GLOBALS['_include_stylesheet'])) {
-            unset($package_elements['base-style.css']);
             self::addStylesheet($GLOBALS['_include_stylesheet'], ['media' => 'screen, print']);
         }
 
diff --git a/lib/classes/StudipArrayObject.class.php b/lib/classes/StudipArrayObject.class.php
index c1aa0f32f80..bb5444c6188 100644
--- a/lib/classes/StudipArrayObject.class.php
+++ b/lib/classes/StudipArrayObject.class.php
@@ -89,7 +89,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
     public function __set($key, $value)
     {
         if ($this->flag == self::ARRAY_AS_PROPS) {
-            return $this->offsetSet($key, $value);
+            $this->offsetSet($key, $value);
+            return;
         }
 
         $this->validateKeyUsage($key);
@@ -106,7 +107,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
     public function __unset($key)
     {
         if ($this->flag == self::ARRAY_AS_PROPS) {
-            return $this->offsetUnset($key);
+            $this->offsetUnset($key);
+            return;
         }
 
         $this->validateKeyUsage($key);
@@ -122,7 +124,6 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
      */
     public function __get($key)
     {
-        $ret = null;
         if ($this->flag == self::ARRAY_AS_PROPS) {
             $ret = $this->offsetGet($key);
             return $ret;
@@ -300,7 +301,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
     public function offsetSet($key, $value)
     {
         if (is_null($key)) {
-            return $this->append($value);
+            $this->append($value);
+            return;
         }
         $this->storage[$key] = $value;
     }
diff --git a/lib/classes/StudipSemTreeViewSimple.class.php b/lib/classes/StudipSemTreeViewSimple.class.php
index fee30abffa1..e2150472b3a 100644
--- a/lib/classes/StudipSemTreeViewSimple.class.php
+++ b/lib/classes/StudipSemTreeViewSimple.class.php
@@ -44,7 +44,7 @@ class StudipSemTreeViewSimple
     * constructor
     *
     */
-    public function __construct($start_item_id = "root", $sem_number = false, $sem_status, $visible_only = false)
+    public function __construct($start_item_id = 'root', $sem_number = false, $sem_status = false, $visible_only = false)
     {
         $this->start_item_id = ($start_item_id) ? $start_item_id : "root";
         $this->root_content = $GLOBALS['UNI_INFO'];
@@ -75,7 +75,7 @@ class StudipSemTreeViewSimple
                         <div class="sem-path">'.
                             '<div class="sem-path-dir">'.
                                 $this->getSemPath($start_id);
-                    echo 
+                    echo
                         '</div>
                         <div class="sem_path_info">
                             <div class="sem_path_title">'.
@@ -179,7 +179,7 @@ class StudipSemTreeViewSimple
         return $ret;
     }
 
-    public function showContent($item_id, $num_all_entries)
+    public function showContent($item_id, $num_all_entries = 0)
     {
         echo "\n<div align=\"left\" style=\"margin-top:10px;margin-bottom:10px;font-size:10pt\">";
         if ($item_id != "root"){
diff --git a/lib/classes/coursewizardsteps/LVGroupsWizardStep.php b/lib/classes/coursewizardsteps/LVGroupsWizardStep.php
index 93f2c1b98b0..0dbf0582b72 100644
--- a/lib/classes/coursewizardsteps/LVGroupsWizardStep.php
+++ b/lib/classes/coursewizardsteps/LVGroupsWizardStep.php
@@ -224,7 +224,7 @@ class LVGroupsWizardStep implements CourseWizardStep
             }
 
             $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views');
-            $html = $factory->render('course/wizard/steps/lvgroups/lvgroup_searchentry', compact('area', 'inlist'));
+            $html = $factory->render('course/wizard/steps/lvgroups/lvgroup_searchentry', compact('area'));
             $data = [
                 'id' => $area->id,
                 'html_string' => $html
diff --git a/lib/classes/librarysearch/resultparsers/BASELibraryResultParser.class.php b/lib/classes/librarysearch/resultparsers/BASELibraryResultParser.class.php
index c1025f5efab..b92628f1ce6 100644
--- a/lib/classes/librarysearch/resultparsers/BASELibraryResultParser.class.php
+++ b/lib/classes/librarysearch/resultparsers/BASELibraryResultParser.class.php
@@ -144,13 +144,15 @@ class BASELibraryResultParser implements LibraryResultParser
     /**
      * @see LibraryResultParser::readRecord
      */
-    public function readRecord($data = '') : LibraryDocument
+    public function readRecord($data = ''): LibraryDocument
     {
-        $dom = new \DOMDocument();
+        $dom = new DOMDocument();
         @$dom->loadXML($data);
         $record = $dom->getElementsByTagName('doc')[0];
         if ($record) {
            return $this->readXMLRecord($record);
         }
+
+        throw new Exception('Could not read record');
     }
 }
diff --git a/lib/classes/librarysearch/resultparsers/MarcxmlLibraryResultParser.class.php b/lib/classes/librarysearch/resultparsers/MarcxmlLibraryResultParser.class.php
index 37225ee2823..8017f3db1ee 100644
--- a/lib/classes/librarysearch/resultparsers/MarcxmlLibraryResultParser.class.php
+++ b/lib/classes/librarysearch/resultparsers/MarcxmlLibraryResultParser.class.php
@@ -201,12 +201,14 @@ class MarcxmlLibraryResultParser implements LibraryResultParser
      */
     public function readRecord($data = ''): LibraryDocument
     {
-        $dom = new \DOMDocument();
+        $dom = new DOMDocument();
         $dom->loadXML($data);
         $record = $dom->getElementsByTagName('record')[0];
         if ($record instanceof \DOMElement) {
             return $this->readResultNode($record);
         }
+
+        throw new Exception('Could not read record');
     }
 
     /**
diff --git a/lib/classes/librarysearch/resultparsers/SRULibraryResultParser.class.php b/lib/classes/librarysearch/resultparsers/SRULibraryResultParser.class.php
index 2bacba19fe3..fed92f39468 100644
--- a/lib/classes/librarysearch/resultparsers/SRULibraryResultParser.class.php
+++ b/lib/classes/librarysearch/resultparsers/SRULibraryResultParser.class.php
@@ -68,7 +68,7 @@ class SRULibraryResultParser implements LibraryResultParser
     /**
      * @see LibraryResultParser::readRecord
      */
-    public function readRecord($data = '') : LibraryDocument
+    public function readRecord($data = ''): LibraryDocument
     {
         $dom = new \DOMDocument();
         @$dom->loadXML($data);
@@ -88,9 +88,9 @@ class SRULibraryResultParser implements LibraryResultParser
             $document = $parser->readResultNode($record);
             if ($document->getTitle()) {
                 return $document;
-            } else {
-                return null;
             }
         }
+
+        throw new Exception('Could not read record');
     }
 }
diff --git a/lib/dbviews/range_tree.view.php b/lib/dbviews/range_tree.view.php
index e9124cabc58..8d3af86fdb4 100644
--- a/lib/dbviews/range_tree.view.php
+++ b/lib/dbviews/range_tree.view.php
@@ -25,10 +25,14 @@
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // +---------------------------------------------------------------------------+
 
+$sem_start_times = [];
 foreach (Semester::findAllVisible() as $key => $value){
     if (isset($value['beginn']) && $value['beginn'])
       $sem_start_times[] = $value['beginn'];
 }
+
+$_views = [];
+
 $_views['sem_number_sql'] = "INTERVAL(start_time," . join(",",$sem_start_times) .")";
 $_views['sem_number_end_sql'] = "IF(duration_time=-1,-1,INTERVAL(start_time+duration_time," . join(",",$sem_start_times) ."))";
 
@@ -80,4 +84,5 @@ $_views["CAT_DEL"] = ["query" => "DELETE FROM kategorien WHERE kategorie_id IN (
 $_views["CAT_DEL_RANGE"] = ["query" => "DELETE FROM kategorien WHERE range_id IN (&)"];
 
 $_views["STATUS_COUNT"] = ["query"=>"SELECT count(DISTINCT user_id) AS anzahl FROM statusgruppen LEFT JOIN statusgruppe_user USING(statusgruppe_id) WHERE range_id=?"];
-?>
+
+return $_views;
diff --git a/lib/dbviews/sem_tree.view.php b/lib/dbviews/sem_tree.view.php
index 4799137bb25..f82767dd1eb 100644
--- a/lib/dbviews/sem_tree.view.php
+++ b/lib/dbviews/sem_tree.view.php
@@ -25,12 +25,13 @@
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // +---------------------------------------------------------------------------+
 
-
+$sem_start_times = [];
 foreach (Semester::findAllVisible() as $key => $value){
     if (isset($value['beginn']) && $value['beginn'])
       $sem_start_times[] = $value['beginn'];
 }
 
+$_views = [];
 $_views['sem_number_sql'] = "INTERVAL(start_time," . join(",",$sem_start_times) .")";
 $_views['sem_number_end_sql'] = "IF(duration_time=-1,-1,INTERVAL(start_time+duration_time," . join(",",$sem_start_times) ."))";
 
@@ -104,4 +105,5 @@ $_views["SEM_INST_GET_SEM"] = ["query" => "SELECT c.Seminar_id, " . $_views['sem
 
 $_views["SEM_USER_GET_SEM"] = ["query" =>"SELECT b.Seminar_id,b.Name, " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminar_user a LEFT JOIN seminare b USING(Seminar_id)
                                             WHERE b.visible=1 AND a.user_id=? AND a.status=?  §"];
-?>
+
+return $_views;
diff --git a/lib/extern/elements/ExternElementLinkInternSimple.class.php b/lib/extern/elements/ExternElementLinkInternSimple.class.php
index 1d3ecc79615..d4765075f58 100644
--- a/lib/extern/elements/ExternElementLinkInternSimple.class.php
+++ b/lib/extern/elements/ExternElementLinkInternSimple.class.php
@@ -70,8 +70,6 @@ class ExternElementLinkInternSimple extends ExternElement {
     function toStringEdit ($post_vars = "", $faulty_values = "",
             $edit_form = "", $anker = "") {
         global $EXTERN_MODULE_TYPES;
-        $out = "";
-        $table = "";
         if ($edit_form == "") {
             $edit_form = new ExternEditModule($this->config, $post_vars, $faulty_values, $anker);
         }
@@ -95,11 +93,12 @@ class ExternElementLinkInternSimple extends ExternElement {
         if (is_array($configs) && count($configs)) {
             $module_name = $EXTERN_MODULE_TYPES[$this->link_module_type]["module"];
             $values = array_keys($configs[$module_name]);
-            unset($names);
-            foreach ($configs[$module_name] as $config)
+
+            $names = [];
+            foreach ($configs[$module_name] as $config) {
                 $names[] = $config["name"];
-        }
-        else {
+            }
+        } else {
             $values = [];
             $names = [];
         }
diff --git a/lib/extern/modules/views/ExternSemLectureTree.class.php b/lib/extern/modules/views/ExternSemLectureTree.class.php
index 6ea8afa5d1e..02820e8014b 100644
--- a/lib/extern/modules/views/ExternSemLectureTree.class.php
+++ b/lib/extern/modules/views/ExternSemLectureTree.class.php
@@ -5,11 +5,11 @@
 # Lifter010: TODO
 
 class ExternSemLectureTree extends StudipSemTreeViewSimple {
-    
+
     var $config;
     var $param;
     var $root_id;
-    
+
     function __construct(&$config, $start_item_id = "", $sem_number = FALSE)
     {
         $this->config = $config;
@@ -21,7 +21,7 @@ class ExternSemLectureTree extends StudipSemTreeViewSimple {
 
         $this->start_item_id = ($start_item_id) ? $start_item_id : $this->root_id;
         $this->param = "range_id={$this->config->range_id}&module=Semlecturetree&config_id={$this->config->id}&";
-        
+
         parent::__construct($this->start_item_id, $sem_number);
     }
 
@@ -63,7 +63,7 @@ class ExternSemLectureTree extends StudipSemTreeViewSimple {
         }
         echo "</table>\n";
     }
-    
+
     function backLink ($item_id) {
         if ($item_id != $this->root_id){
             echo "<table width=\"100%\" border=\"0\"";
@@ -82,7 +82,7 @@ class ExternSemLectureTree extends StudipSemTreeViewSimple {
         }
     }
 
-    function showContent ($item_id) {
+    function showContent ($item_id, $num_all_entries = 0) {
         echo "<table" . $this->config->getAttributes("TreeLevelName", "table");
         echo ">\n<tr><td" . $this->config->getAttributes("TreeLevelName", "td") . ">";
         echo "<font" . $this->config->getAttributes("TreeLevelName", "font") . ">";
@@ -115,10 +115,10 @@ class ExternSemLectureTree extends StudipSemTreeViewSimple {
             $ret .= $delimiter;
         $ret .= htmlReady($this->tree->tree_data[$this->start_item_id]["name"]);
         $ret .= "</font></td></tr></table>\n";
-        
+
         return $ret;
     }
-    
+
 }
 
 ?>
diff --git a/lib/ilias_interface/IliasSoap.class.php b/lib/ilias_interface/IliasSoap.class.php
index bf313e85142..93f34970fb1 100644
--- a/lib/ilias_interface/IliasSoap.class.php
+++ b/lib/ilias_interface/IliasSoap.class.php
@@ -87,8 +87,9 @@ class IliasSoap extends StudipSoapClient
             return $this->admin_sid;
         }
         if ($this->user_type == "user") {
-            if ($this->user_sid == false)
-                $this->loginUser();
+            if ($this->user_sid == false) {
+                throw new Exception('Not implemented');
+            }
             return $this->user_sid;
         }
         return false;
diff --git a/lib/modules/CoreForum.class.php b/lib/modules/CoreForum.class.php
index 88dd5ddc7f7..ba1ee64f7e2 100644
--- a/lib/modules/CoreForum.class.php
+++ b/lib/modules/CoreForum.class.php
@@ -163,12 +163,12 @@ class CoreForum extends CorePlugin implements ForumModule
 
     public function migrateUser($user_from, $user_to)
     {
-        return ForumEntry::migrateUser($user_from, $user_to);
+        ForumEntry::migrateUser($user_from, $user_to);
     }
 
     public function deleteContents($seminar_id)
     {
-        return ForumEntry::delete($seminar_id);
+        ForumEntry::delete($seminar_id);
     }
 
     public function getDump($seminar_id)
-- 
GitLab