From 832921ba04219c56a98832e1b226cd29b4d3cc1a Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Mon, 4 Nov 2024 14:16:47 +0000
Subject: [PATCH] prevent warnings in admin-va, fixes  #4809

Closes #4809

Merge request studip/studip!3600
---
 app/controllers/admin/courses.php             |  2 --
 app/views/admin/courses/additional_inputs.php | 36 -------------------
 app/views/admin/courses/aux_preselect.php     |  5 ++-
 app/views/admin/courses/lock_preselect.php    | 10 +++---
 4 files changed, 6 insertions(+), 47 deletions(-)
 delete mode 100644 app/views/admin/courses/additional_inputs.php

diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php
index 7cdf64e79c2..b85f682e7cc 100644
--- a/app/controllers/admin/courses.php
+++ b/app/controllers/admin/courses.php
@@ -429,7 +429,6 @@ class Admin_CoursesController extends AuthenticatedController
                 break;
             case 8: //Sperrebenen
                 $template = $tf->open('admin/courses/lock_preselect');
-                $template->course = $course;
                 $template->all_lock_rules = new SimpleCollection(array_merge(
                     [[
                         'name'    => '--' . _('keine Sperrebene') . '--',
@@ -446,7 +445,6 @@ class Admin_CoursesController extends AuthenticatedController
                 break;
             case 10: //Zusatzangaben
                 $template = $tf->open('admin/courses/aux_preselect');
-                $template->course = $course;
                 $template->aux_lock_rules = AuxLockRule::findBySQL('1 ORDER BY name ASC');
                 $data['buttons_top'] = $template->render();
                 $data['buttons_bottom'] = (string) \Studip\Button::createAccept(_('Zusatzangaben'), 'aux_button', ['formaction' => URLHelper::getURL('dispatch.php/admin/courses/set_aux_lockrule')]);
diff --git a/app/views/admin/courses/additional_inputs.php b/app/views/admin/courses/additional_inputs.php
deleted file mode 100644
index 54c32e931fb..00000000000
--- a/app/views/admin/courses/additional_inputs.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * @var string $colspan
- * @var string $selected_action
- * @var string $selected_action
- * @var array $values
- */
-?>
-<tr>
-    <th colspan="<?= $colspan ?>" style="text-align: right">
-        <? switch ($selected_action) {
-            case 8 :
-                echo $this->render_partial('admin/courses/lock_preselect.php', compact('values', 'semid'));
-                break;
-            default:
-            case 9:
-                echo '<label>', _('Alle auswählen'), '<input title="', _('Alle auswählen'), '"
-                                type="checkbox" name="all" value="1" data-proxyfor=".course-admin td:last-child :checkbox" aria-label="',
-                _('Alle auswählen'), '"/></label>';
-                break;
-            case 10:
-                echo $this->render_partial('admin/courses/aux_preselect.php', compact('values', 'semid'));
-                break;
-            case 16:
-                echo '<label>', _('Alle auswählen'), '<input title="', _('Alle auswählen'), '"
-                                type="checkbox" name="all" value="1" data-proxyfor=":checkbox[name^=archiv_sem]" aria-label="',
-                _('Alle auswählen'), '"/></label>';
-                break;
-            case 17:
-                echo '<label>', _('Alle auswählen'), '<input title="', _('Alle auswählen'), '"
-                                type="checkbox" name="all" value="1" data-proxyfor=":checkbox[name^=admission_locked]" aria-label="',
-                _('Alle auswählen'), '"/></label>';
-                break;
-        }?>
-    </th>
-</tr>
diff --git a/app/views/admin/courses/aux_preselect.php b/app/views/admin/courses/aux_preselect.php
index d7fd801eb2a..102e660e039 100644
--- a/app/views/admin/courses/aux_preselect.php
+++ b/app/views/admin/courses/aux_preselect.php
@@ -1,17 +1,16 @@
 <?php
 /**
- * @var array $values
  * @var AuxLockRule[] $aux_lock_rules
  */
 ?>
+
 <label><?= _('Für alle Veranstaltungen') ?>
     <select name="lock_sem_all" style="max-width: 200px">
         <option value="none">
             --<?= _('keine Zusatzangaben') ?>--
         </option>
     <? foreach ($aux_lock_rules as $rule) : ?>
-        <option value="<?= htmlReady($rule->id) ?>"
-            <? if ($values['aux_lock_rule'] === $rule->id) echo 'selected'; ?>>
+        <option value="<?= htmlReady($rule->id) ?>">
             <?= htmlReady($rule->name) ?>
         </option>
     <? endforeach ?>
diff --git a/app/views/admin/courses/lock_preselect.php b/app/views/admin/courses/lock_preselect.php
index 433230e73ae..90943245670 100644
--- a/app/views/admin/courses/lock_preselect.php
+++ b/app/views/admin/courses/lock_preselect.php
@@ -1,17 +1,15 @@
 <?php
 /**
- * @var Course $course
  * @var SimpleCollection $all_lock_rules
  */
 ?>
 <label><?= _('Für alle Veranstaltungen') ?>
     <select name="lock_sem_all" style="max-width: 200px">
-        <? for ($i = 0; $i < count($all_lock_rules); $i++) : ?>
-            <option value="<?= $all_lock_rules[$i]["lock_id"] ?>"
-                <?= $all_lock_rules[$i]['lock_id'] === $course->lock_rule ? 'selected' : '' ?>>
-                <?= htmlReady($all_lock_rules[$i]["name"]) ?>
+        <? foreach ($all_lock_rules as $lock_rule): ?>
+            <option value="<?= htmlReady($lock_rule->id) ?>">
+                <?= htmlReady($lock_rule->name) ?>
             </option>
-        <? endfor ?>
+        <? endforeach ?>
     </select>
 </label>
 
-- 
GitLab