From c91fbd09075348c9b7b08900b7dbe7056eb75a63 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Wed, 7 Aug 2024 09:47:14 +0000
Subject: [PATCH] link courses and institutes in admin user view, fixes #4457

Closes #4457

Merge request studip/studip!3242
---
 app/views/admin/user/_course_files.php    | 50 +++++++++++++----------
 app/views/admin/user/_institute_files.php | 32 ++++++++-------
 2 files changed, 46 insertions(+), 36 deletions(-)

diff --git a/app/views/admin/user/_course_files.php b/app/views/admin/user/_course_files.php
index af623963da5..caac81ad8d3 100644
--- a/app/views/admin/user/_course_files.php
+++ b/app/views/admin/user/_course_files.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * @var Admin_UserController $controller
- * @var array $course_files
+ * @var array<string, array<string, array{course: Course, files: int}>> $course_files
  * @var array $params
  * @var User $user
  */
@@ -12,8 +12,8 @@
             <?= _('Dateiübersicht Veranstaltungen') ?>
         </h1>
     </header>
-    <? foreach ($course_files as $semester_name => $file_date) : ?>
-        <article id="<?= $semester_name ?>" class="<?= ContentBoxHelper::classes($semester_name) ?>">
+    <? foreach ($course_files as $semester_name => $file_data) : ?>
+        <article id="<?= htmlReady($semester_name) ?>" class="<?= ContentBoxHelper::classes($semester_name) ?>">
             <header>
                 <h1>
                     <a href="<?= ContentBoxHelper::href($semester_name) ?>">
@@ -40,11 +40,17 @@
                         </tr>
                     </thead>
                     <tbody>
-                        <? foreach ($file_date as $data): ?>
+                        <? foreach ($file_data as $data): ?>
                             <tr>
-                                <td><?= htmlReady($data['course']->veranstaltungsnummer) ?></td>
                                 <td>
-                                    <?= htmlReady($data['course']->name) ?>
+                                    <a href="<?= URLHelper::getLink('seminar_main.php', ['auswahl' => $data['course']->id]) ?>">
+                                        <?= htmlReady($data['course']->veranstaltungsnummer) ?>
+                                    </a>
+                                </td>
+                                <td>
+                                    <a href="<?= URLHelper::getLink('seminar_main.php', ['auswahl' => $data['course']->id]) ?>">
+                                        <?= htmlReady($data['course']->name) ?>
+                                    </a>
                                 </td>
                                 <td>
                                     <?= htmlReady($data['course']->getSemType()['name'])?>
@@ -57,23 +63,23 @@
                                     <? endif ?>
                                 </td>
                                 <td class="actions">
-                                    <? if ($data['files']) : ?>
-                                        <?
-                                        $actionMenu = ActionMenu::get()->setContext($data['course']->name);
-                                        $actionMenu->addLink($controller->url_for('admin/user/list_files/' . $user['user_id'] . '/' . $data['course']->id, $params),
-                                                _('Dateien auflisten'),
-                                                Icon::create('folder-full', 'clickable'),
-                                                ['data-dialog' => 'size=50%']);
-                                        $actionMenu->addLink($controller->url_for('admin/user/download_user_files/' . $user['user_id'] . '/' . $data['course']->id),
-                                                _('Dateien als ZIP herunterladen'),
-                                                Icon::create('download', 'clickable'));
-
-                                        ?>
-
-                                        <?= $actionMenu->render() ?>
-                                    <? endif ?>
+                                <? if ($data['files']) : ?>
+                                    <?= ActionMenu::get()
+                                        ->setContext($data['course']->name)
+                                        ->addLink(
+                                            $controller->list_filesURL($user->id, $data['course']->id, $params),
+                                            _('Dateien auflisten'),
+                                            Icon::create('folder-full'),
+                                            ['data-dialog' => 'size=50%']
+                                        )
+                                        ->addLink(
+                                            $controller->download_user_filesURL($user->id, $data['course']->id),
+                                            _('Dateien als ZIP herunterladen'),
+                                            Icon::create('download')
+                                        )
+                                    ?>
+                                <? endif ?>
                                 </td>
-
                             </tr>
                         <? endforeach; ?>
                     </tbody>
diff --git a/app/views/admin/user/_institute_files.php b/app/views/admin/user/_institute_files.php
index 78085dfb855..665e3c6ff48 100644
--- a/app/views/admin/user/_institute_files.php
+++ b/app/views/admin/user/_institute_files.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * @var Admin_UserController $controller
- * @var Institute[] $institutes
+ * @var array<int, array{Institut_id: string, Name: string, files: int}> $institutes
  * @var User $user
  * @var array $params
  */
@@ -32,30 +32,34 @@
                 <? foreach ($institutes as $institute): ?>
                     <tr>
                         <td>
-                            <?= htmlReady($institute['Name']) ?>
+                            <a href="<?= URLHelper::getLink('dispatch.php/institute/overview', ['auswahl' => $institute['Institut_id']]) ?>">
+                                <?= htmlReady($institute['Name']) ?>
+                            </a>
                         </td>
                         <td>
-                            <? if ((int)$institute['files']) : ?>
+                            <? if ($institute['files']) : ?>
                                 <?= sprintf('%u %s', $institute['files'], _('Dokumente')) ?>
                             <? else : ?>
                                 -
                             <? endif ?>
                         </td>
                         <td class="actions">
-                            <? if ($institute['files']) : ?>
-                                <?
-                                $actionMenu = ActionMenu::get()->setContext($institute['Name']);
-                                $actionMenu->addLink($controller->url_for('admin/user/list_files/' . $user['user_id'] . '/' . $institute['Institut_id'] , $params),
+                        <? if ($institute['files']) : ?>
+                            <?= ActionMenu::get()
+                                ->setContext($institute['Name'])
+                                ->addLink(
+                                    $controller->list_filesURL($user->id, $institute['Institut_id'], $params),
                                     _('Dateien auflisten'),
                                     Icon::create('folder-full'),
-                                    ['data-dialog' => 'size=50%']);
-                                $actionMenu->addLink($controller->url_for('admin/user/download_user_files/' . $user['user_id'] . '/' . $institute['Institut_id']),
+                                    ['data-dialog' => 'size=50%']
+                                )
+                                ->addLink(
+                                    $controller->download_user_filesURL($user->id, $institute['Institut_id']),
                                     _('Dateien als ZIP herunterladen'),
-                                    Icon::create('download'));
-
-                                ?>
-                                <?= $actionMenu->render() ?>
-                            <? endif ?>
+                                    Icon::create('download')
+                                )
+                            ?>
+                        <? endif ?>
                         </td>
                     </tr>
                 <? endforeach; ?>
-- 
GitLab