Skip to content
Snippets Groups Projects
Commit e398eec2 authored by Peter Thienel's avatar Peter Thienel Committed by David Siegfried
Browse files

Resolve "Terminkalender: Dialog des Termin-Exports schließt sich nicht nach Download"

Closes #4094

Merge request studip/studip!2938
parent e7bfc2e8
No related branches found
No related tags found
No related merge requests found
...@@ -770,29 +770,41 @@ class Calendar_CalendarController extends AuthenticatedController ...@@ -770,29 +770,41 @@ class Calendar_CalendarController extends AuthenticatedController
PageLayout::postError(_('Bitte wählen Sie aus, welche Termine exportiert werden sollen!')); PageLayout::postError(_('Bitte wählen Sie aus, welche Termine exportiert werden sollen!'));
return; return;
} }
$ical = ''; $this->relocate($this->url_for('calendar/calendar/export_file', [
$calendar_export = new ICalendarExport(); 'begin' => $this->begin->format('d.m.Y'),
if ($this->dates_to_export === 'user') { 'end' => $this->end->format('d.m.Y'),
$ical = $calendar_export->exportCalendarDates(User::findCurrent()->id, $this->begin, $this->end); 'dates_to_export' => $this->dates_to_export
} 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);
} }
} }
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_action() {}
public function import_file_action() public function import_file_action()
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* @var DateTimeImmutable $end * @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) ?>"> action="<?= $controller->link_for('calendar/calendar/export', $user_id ?? null) ?>">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
<fieldset> <fieldset>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment