From 1e4f908251e175b2a48b845749b6c352e6c237bc Mon Sep 17 00:00:00 2001
From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de>
Date: Thu, 2 Nov 2023 10:51:01 +0000
Subject: [PATCH] fix bugs introduced in #1118 (lonely_sem was removed in 4.2),
 fixes #3383

Closes #3383

Merge request studip/studip!2303
---
 lib/classes/ActionMenu.php                    |  3 ---
 lib/classes/StudipSemTreeView.class.php       |  8 +------
 lib/classes/StudipSemTreeViewAdmin.class.php  | 24 ++++++++-----------
 lib/classes/searchtypes/RangeSearch.class.php | 11 +--------
 lib/classes/searchtypes/SQLSearch.class.php   |  1 -
 lib/models/LogEvent.php                       |  2 +-
 6 files changed, 13 insertions(+), 36 deletions(-)

diff --git a/lib/classes/ActionMenu.php b/lib/classes/ActionMenu.php
index aa6c5240e47..07b87a914e2 100644
--- a/lib/classes/ActionMenu.php
+++ b/lib/classes/ActionMenu.php
@@ -199,7 +199,6 @@ class ActionMenu
                 'icon'       => $icon,
                 'label'      => $label,
                 'attributes' => $attributes,
-                'index'      => ''
             ];
         }
 
@@ -218,7 +217,6 @@ class ActionMenu
             $this->actions[] = [
                 'type'   => 'multi-person-search',
                 'object' => $mp,
-                'index'  => ''
             ];
         }
 
@@ -235,7 +233,6 @@ class ActionMenu
         if ($this->checkCondition()) {
             $this->actions[] = [
                 'type'   => 'separator',
-                'index'  => ''
             ];
         }
 
diff --git a/lib/classes/StudipSemTreeView.class.php b/lib/classes/StudipSemTreeView.class.php
index eef3339093e..3e984cc8313 100644
--- a/lib/classes/StudipSemTreeView.class.php
+++ b/lib/classes/StudipSemTreeView.class.php
@@ -146,7 +146,7 @@ class StudipSemTreeView extends TreeView {
         $content .= "<tr><td colspan=\"2\" class=\"table_row_even\">" . sprintf(_("Alle Veranstaltungen innerhalb dieses Bereiches in der %sÃœbersicht%s"),
                 "<a href=\"" . URLHelper::getLink($this->getSelf("cmd=show_sem_range&item_id=$item_id")) ."\">","</a>") . "</td></tr>";
         $content .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
-        if ($this->tree->getNumEntries($item_id) - $this->tree->tree_data[$item_id]['lonely_sem']){
+        if ($this->tree->getNumEntries($item_id)){
             $content .= "<tr><td class=\"table_row_even\" align=\"left\" colspan=\"2\"><b>" . _("Einträge auf dieser Ebene:");
             $content .= "</b>\n</td></tr>";
             $entries = $this->tree->getSemData($item_id);
@@ -154,12 +154,6 @@ class StudipSemTreeView extends TreeView {
         } else {
             $content .= "\n<tr><td class=\"table_row_even\" colspan=\"2\">" . _("Keine Einträge auf dieser Ebene vorhanden!") . "</td></tr>";
         }
-        if ($this->tree->tree_data[$item_id]['lonely_sem']){
-            $content .= "<tr><td class=\"table_row_even\" align=\"left\" colspan=\"2\"><b>" . _("Nicht zugeordnete Veranstaltungen auf dieser Ebene:");
-            $content .= "</b>\n</td></tr>";
-            $entries = $this->tree->getLonelySemData($item_id);
-            $content .= $this->getSemDetails($entries->getGroupedResult("seminar_id"));
-        }
         $content .= "</table>";
         return $content;
     }
diff --git a/lib/classes/StudipSemTreeViewAdmin.class.php b/lib/classes/StudipSemTreeViewAdmin.class.php
index c615f9859e1..edc65c8b3a7 100644
--- a/lib/classes/StudipSemTreeViewAdmin.class.php
+++ b/lib/classes/StudipSemTreeViewAdmin.class.php
@@ -46,8 +46,8 @@ class StudipSemTreeViewAdmin extends TreeView
     var $marked_item;
     var $marked_sem;
     var $mode;
-    var $move_item_id;
-    var $edit_item_id;
+    var $move_item_id = null;
+    var $edit_item_id = null;
 
     /**
     * constructor
@@ -492,12 +492,14 @@ class StudipSemTreeViewAdmin extends TreeView
     }
 
     function getItemContent($item_id){
-        if (!empty($this->edit_item_id) && ($item_id == $this->edit_item_id)) return $this->getEditItemContent();
-        if(empty($GLOBALS['SEM_TREE_TYPES'][$this->tree->getValue($item_id, 'type')]['editable'])){
+        if ($item_id == $this->edit_item_id) {
+            return $this->getEditItemContent();
+        }
+        if (empty($GLOBALS['SEM_TREE_TYPES'][$this->tree->getValue($item_id, 'type')]['editable'])){
             $is_not_editable = true;
             $this->msg[$item_id] = "info§" . sprintf(_("Der Typ dieses Elementes verbietet eine Bearbeitung."));
         }
-        if (!empty($this->move_item_id) && ($item_id == $this->move_item_id)) {
+        if ($item_id == $this->move_item_id) {
             $this->msg[$item_id] = "info§" . sprintf(_("Dieses Element wurde zum Verschieben / Kopieren markiert. Bitte wählen Sie ein Einfügesymbol %s aus, um das Element zu verschieben / kopieren."), Icon::create('arr_2right', 'sort', ['title' => "Einfügesymbol"])->asImg(16, ["alt" => "Einfügesymbol"]));
         }
         $content = "\n<table width=\"90%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" style=\"font-size:10pt;\">";
@@ -521,7 +523,7 @@ class StudipSemTreeViewAdmin extends TreeView
                         URLHelper::getURL($this->getSelf('cmd=AssertDeleteItem&item_id=' . $item_id)),
                         ['title' => _('Dieses Element löschen')]) . '&nbsp;';
 
-                if (!empty($this->move_item_id) && ($this->move_item_id == $item_id) && ($this->mode == "MoveItem" || $this->mode == "CopyItem")){
+                if ($this->move_item_id == $item_id && ($this->mode == "MoveItem" || $this->mode == "CopyItem")){
                     $content .= LinkButton::create(_('Abbrechen'),
                             URLHelper::getURL($this->getSelf('cmd=Cancel&item_id=' . $item_id)),
                             ['title' => _('Verschieben / Kopieren abbrechen')]) . '&nbsp;';
@@ -562,7 +564,7 @@ class StudipSemTreeViewAdmin extends TreeView
             $content .= formatReady($this->tree->tree_data[$item_id]['info']) . "</td></tr>";
         }
         $content .= "<tr><td style=\"font-size:10pt;\"colspan=\"3\">&nbsp;</td></tr>";
-        if (!empty($this->tree->tree_data[$item_id]['lonely_sem']) && ($this->tree->getNumEntries($item_id) - $this->tree->tree_data[$item_id]['lonely_sem'])) {
+        if ($this->tree->getNumEntries($item_id)) {
             $content .= "<tr><td class=\"table_row_even\" style=\"font-size:10pt;\" align=\"left\" colspan=\"3\"><b>" . _("Einträge auf dieser Ebene:");
             $content .= "</b>\n</td></tr>";
             $entries = $this->tree->getSemData($item_id);
@@ -570,12 +572,6 @@ class StudipSemTreeViewAdmin extends TreeView
         } else {
             $content .= "\n<tr><td class=\"table_row_even\" style=\"font-size:10pt;\" colspan=\"3\">" . _("Keine Einträge auf dieser Ebene vorhanden!") . "</td></tr>";
         }
-        if (!empty($this->tree->tree_data[$item_id]['lonely_sem'])) {
-            $content .= "<tr><td class=\"table_row_even\" align=\"left\" style=\"font-size:10pt;\" colspan=\"3\"><b>" . _("Nicht zugeordnete Veranstaltungen auf dieser Ebene:");
-            $content .= "</b>\n</td></tr>";
-            $entries = $this->tree->getLonelySemData($item_id);
-            $content .= $this->getSemDetails($entries,$item_id,true);
-        }
         $content .= "</table>";
         return $content;
     }
@@ -776,7 +772,7 @@ class StudipSemTreeViewAdmin extends TreeView
         if ($item_id != "root"){
             $head .= " (" . $this->tree->getNumEntries($item_id,true) . ") " ;
         }
-        if ($item_id != $this->start_item_id && $this->isParentAdmin($item_id) && !empty($this->edit_item_id) && ($item_id != $this->edit_item_id)){
+        if ($item_id != $this->start_item_id && $this->isParentAdmin($item_id) && $item_id != $this->edit_item_id){
             $head .= "</td><td nowrap align=\"right\" valign=\"bottom\" class=\"printhead\">";
             if (!$this->tree->isFirstKid($item_id)){
                 $head .= "<a href=\"". URLHelper::getLink($this->getSelf("cmd=OrderItem&direction=up&item_id=$item_id")) .
diff --git a/lib/classes/searchtypes/RangeSearch.class.php b/lib/classes/searchtypes/RangeSearch.class.php
index b9c83ae07f0..caefae0bc0e 100644
--- a/lib/classes/searchtypes/RangeSearch.class.php
+++ b/lib/classes/searchtypes/RangeSearch.class.php
@@ -4,17 +4,8 @@
  * @license     GPL2 or any later version
  * @category    Stud.IP
  */
-class RangeSearch extends SQLSearch
+class RangeSearch extends SearchType
 {
-    public $search;
-
-    public function __construct()
-    {
-        $this->avatarLike = $this->search = '';
-        $this->sql = $this->getSQL();
-    }
-
-
     /**
      * returns the title/description of the searchfield
      *
diff --git a/lib/classes/searchtypes/SQLSearch.class.php b/lib/classes/searchtypes/SQLSearch.class.php
index f69a65e4d28..86aff6dcbf0 100644
--- a/lib/classes/searchtypes/SQLSearch.class.php
+++ b/lib/classes/searchtypes/SQLSearch.class.php
@@ -37,7 +37,6 @@ class SQLSearch extends SearchType
     protected $sql;
     protected $avatarLike;
     protected $title;
-    public $extendedLayout = false;
 
     /**
      *
diff --git a/lib/models/LogEvent.php b/lib/models/LogEvent.php
index 547447e48f1..8be1f74b840 100644
--- a/lib/models/LogEvent.php
+++ b/lib/models/LogEvent.php
@@ -279,7 +279,7 @@ class LogEvent extends SimpleORMap implements PrivacyObject
     protected function formatSemester($field) {
         $all_semester = Semester::findAllVisible(false);
         foreach ($all_semester as $val) {
-            if (!empty($val['beginn']) && ($val['beginn'] == $this->$field)) {
+            if ($val['beginn'] == $this->$field) {
                 return '<em>' . htmlReady($val['name']) . '</em>';
             }
         }
-- 
GitLab