Skip to content
Snippets Groups Projects
Commit a636dcb3 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #3922

Closes #3922

Merge request studip/studip!2792
parent ce637772
No related branches found
No related tags found
No related merge requests found
...@@ -78,6 +78,15 @@ class Calendar_ContentboxController extends StudipController ...@@ -78,6 +78,15 @@ class Calendar_ContentboxController extends StudipController
if ($this->admin) { if ($this->admin) {
$this->isProfile = $this->single && $this->userRange; $this->isProfile = $this->single && $this->userRange;
} }
// Sort dates
usort($this->termine, function ($a, $b) {
[$a_begin, $a_end] = $this->parseBeginAndEndFromDate($a);
[$b_begin, $b_end] = $this->parseBeginAndEndFromDate($b);
return $a_begin - $b_begin
?: $a_end - $b_end;
});
} }
private function parseSeminar($id) private function parseSeminar($id)
...@@ -170,4 +179,23 @@ class Calendar_ContentboxController extends StudipController ...@@ -170,4 +179,23 @@ class Calendar_ContentboxController extends StudipController
$this->termine[] = $assignment; $this->termine[] = $assignment;
} }
} }
private function parseBeginAndEndFromDate($date): array
{
if ($date instanceof CalendarDateAssignment) {
return [
$date->calendar_date->begin,
$date->calendar_date->end,
];
}
if ($date instanceof CourseDate || $date instanceof CourseExDate) {
return [
$date->date,
$date->end_time,
];
}
throw new Exception('Invalid date type passed: ' . get_class($date));
}
} }
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