From e398eec260ff49cfd347246f143e629905de6f5e Mon Sep 17 00:00:00 2001 From: Peter Thienel <thienel@data-quest.de> Date: Mon, 6 May 2024 09:14:14 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20"Terminkalender:=20Dialog=20des=20Ter?= =?UTF-8?q?min-Exports=20schlie=C3=9Ft=20sich=20nicht=20nach=20Download"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4094 Merge request studip/studip!2938 --- app/controllers/calendar/calendar.php | 52 ++++++++++++++++---------- app/views/calendar/calendar/export.php | 2 +- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/app/controllers/calendar/calendar.php b/app/controllers/calendar/calendar.php index 0c24a8025d0..d0d574391c5 100644 --- a/app/controllers/calendar/calendar.php +++ b/app/controllers/calendar/calendar.php @@ -770,29 +770,41 @@ class Calendar_CalendarController extends AuthenticatedController PageLayout::postError(_('Bitte wählen Sie aus, welche Termine exportiert werden sollen!')); return; } - $ical = ''; - $calendar_export = new ICalendarExport(); - if ($this->dates_to_export === 'user') { - $ical = $calendar_export->exportCalendarDates(User::findCurrent()->id, $this->begin, $this->end); - } elseif ($this->dates_to_export === 'course') { - $ical = $calendar_export->exportCourseDates(User::findCurrent()->id, $this->begin, $this->end); - $ical .= $calendar_export->exportCourseExDates(User::findCurrent()->id, $this->begin, $this->end); - } elseif ($this->dates_to_export === 'all') { - $ical = $calendar_export->exportCalendarDates(User::findCurrent()->id, $this->begin, $this->end); - $ical .= $calendar_export->exportCourseDates(User::findCurrent()->id, $this->begin, $this->end); - $ical .= $calendar_export->exportCourseExDates(User::findCurrent()->id, $this->begin, $this->end); - } - $ical = $calendar_export->writeHeader() . $ical . $calendar_export->writeFooter(); - $this->response->add_header('Content-Type', 'text/calendar;charset=utf-8'); - $this->response->add_header('Content-Disposition', 'attachment; filename="studip.ics"'); - $this->response->add_header('Content-Transfer-Encoding', 'binary'); - $this->response->add_header('Pragma', 'public'); - $this->response->add_header('Cache-Control', 'private'); - $this->response->add_header('Content-Length', strlen($ical)); - $this->render_text($ical); + $this->relocate($this->url_for('calendar/calendar/export_file', [ + 'begin' => $this->begin->format('d.m.Y'), + 'end' => $this->end->format('d.m.Y'), + 'dates_to_export' => $this->dates_to_export + ])); } } + public function export_file_action() + { + $begin = Request::getDateTime('begin', 'd.m.Y'); + $end = Request::getDateTime('end', 'd.m.Y'); + $dates_to_export = Request::option('dates_to_export', 'user'); + $ical = ''; + $calendar_export = new ICalendarExport(); + if ($dates_to_export === 'user') { + $ical = $calendar_export->exportCalendarDates(User::findCurrent()->id, $begin, $end); + } elseif ($dates_to_export === 'course') { + $ical = $calendar_export->exportCourseDates(User::findCurrent()->id, $begin, $end); + $ical .= $calendar_export->exportCourseExDates(User::findCurrent()->id, $begin, $end); + } elseif ($dates_to_export === 'all') { + $ical = $calendar_export->exportCalendarDates(User::findCurrent()->id, $begin, $end); + $ical .= $calendar_export->exportCourseDates(User::findCurrent()->id, $begin, $end); + $ical .= $calendar_export->exportCourseExDates(User::findCurrent()->id, $begin, $end); + } + $ical = $calendar_export->writeHeader() . $ical . $calendar_export->writeFooter(); + $this->response->add_header('Content-Type', 'text/calendar;charset=utf-8'); + $this->response->add_header('Content-Disposition', 'attachment; filename="studip.ics"'); + $this->response->add_header('Content-Transfer-Encoding', 'binary'); + $this->response->add_header('Pragma', 'public'); + $this->response->add_header('Cache-Control', 'private'); + $this->response->add_header('Content-Length', strlen($ical)); + $this->render_text($ical); + } + public function import_action() {} public function import_file_action() diff --git a/app/views/calendar/calendar/export.php b/app/views/calendar/calendar/export.php index 0ff766d6859..b4171feb70c 100644 --- a/app/views/calendar/calendar/export.php +++ b/app/views/calendar/calendar/export.php @@ -7,7 +7,7 @@ * @var DateTimeImmutable $end */ ?> -<form class="default" method="post" +<form class="default" method="post" data-dialog="size=auto" action="<?= $controller->link_for('calendar/calendar/export', $user_id ?? null) ?>"> <?= CSRFProtection::tokenTag() ?> <fieldset> -- GitLab