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,17 +770,30 @@ class Calendar_CalendarController extends AuthenticatedController
PageLayout::postError(_('Bitte wählen Sie aus, welche Termine exportiert werden sollen!'));
return;
}
$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 ($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);
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');
......@@ -791,7 +804,6 @@ class Calendar_CalendarController extends AuthenticatedController
$this->response->add_header('Content-Length', strlen($ical));
$this->render_text($ical);
}
}
public function import_action() {}
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment