From 3d4b1124bbbb07ffb9e656432f7a6a971d207897 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Tue, 23 Apr 2024 11:49:14 +0000 Subject: [PATCH] set user_id or group_id when calling calendar/date/add from sidebar, fixes #4058 Closes #4058 Merge request studip/studip!2910 --- app/controllers/calendar/calendar.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/controllers/calendar/calendar.php b/app/controllers/calendar/calendar.php index 85b5b433dc2..0c24a8025d0 100644 --- a/app/controllers/calendar/calendar.php +++ b/app/controllers/calendar/calendar.php @@ -12,8 +12,12 @@ class Calendar_CalendarController extends AuthenticatedController } - protected function buildSidebar($schedule = false) - { + protected function buildSidebar( + bool $schedule = false, + string $user_id = '', + string $group_id = '' + ) { + $sidebar = Sidebar::get(); $actions = new ActionsWidget(); @@ -25,9 +29,15 @@ class Calendar_CalendarController extends AuthenticatedController ['data-dialog' => 'size=default'] ); } else { + $params = []; + if ($user_id) { + $params['user_id'] = $user_id; + } elseif ($group_id) { + $params['group_id'] = $group_id; + } $actions->addLink( _('Termin anlegen'), - $this->url_for('calendar/date/add'), + $this->url_for('calendar/date/add', $params), Icon::create('add'), ['data-dialog' => 'size=auto'] ); @@ -181,7 +191,11 @@ class Calendar_CalendarController extends AuthenticatedController throw new AccessDeniedException(_('Sie dürfen diesen Kalender nicht sehen!')); } - $this->buildSidebar(false); + $this->buildSidebar( + false, + $calendar_owner ? $calendar_owner->id : '', + $selected_group ? $selected_group->id : '' + ); $sidebar = Sidebar::get(); -- GitLab