From ed00a0fbd4342f1d30bed8615a8a8273b5d17cdd Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Fri, 3 Nov 2023 12:34:30 +0000
Subject: [PATCH] add sharable link to consultation overview and redirect
 unpriviledged users to...

Closes #3373

Merge request studip/studip!2325
---
 app/controllers/consultation/admin.php    | 15 ++++++++++++++-
 app/controllers/consultation/overview.php |  1 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php
index 47d2ecdda94..b335e360401 100644
--- a/app/controllers/consultation/admin.php
+++ b/app/controllers/consultation/admin.php
@@ -17,7 +17,8 @@ class Consultation_AdminController extends ConsultationController
         parent::before_filter($action, $args);
 
         if (!$this->range->isEditableByUser()) {
-            throw new AccessDeniedException();
+            $this->redirect('consultation/overview');
+            return;
         }
 
         $this->activateNavigation('admin');
@@ -846,6 +847,18 @@ class Consultation_AdminController extends ConsultationController
             $this->url_for('consultation/export/all', $action === 'expired'),
             Icon::create('export')
         );
+
+        if ($action !== 'expired') {
+            $share = new ShareWidget();
+            $share->addCopyableLink(
+                _('Link zur Terminübersicht kopieren'),
+                $this->url_for('consultation/overview', [
+                    'again'  => 'yes',
+                ]),
+                Icon::create('clipboard')
+            );
+            $sidebar->addWidget($share);
+        }
     }
 
     private function getDateAndTime($index)
diff --git a/app/controllers/consultation/overview.php b/app/controllers/consultation/overview.php
index e7456da5d9a..c8085f2cd3a 100644
--- a/app/controllers/consultation/overview.php
+++ b/app/controllers/consultation/overview.php
@@ -16,6 +16,7 @@ class Consultation_OverviewController extends ConsultationController
 
         if ($this->range->isEditableByUser()) {
             $this->redirect('consultation/admin');
+            return;
         }
 
         PageLayout::setTitle(sprintf(
-- 
GitLab