Skip to content
Snippets Groups Projects
Commit 6b3ca21b authored by Moritz Strohm's avatar Moritz Strohm Committed by David Siegfried
Browse files

TIC #842

Merge request studip/studip!491
parent 5866bdf1
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,19 @@ class ProfileModel
public function getDozentSeminars()
{
$courses = [];
$semester = array_reverse(Semester::getAll());
$semester = [];
$next_semester = Semester::findNext();
$current_semester = Semester::findCurrent();
$previous_semester = Semester::findPrevious();
if ($next_semester) {
$semester[$next_semester->id] = $next_semester;
}
if ($current_semester) {
$semester[$current_semester->id] = $current_semester;
}
if ($previous_semester) {
$semester[$previous_semester->id] = $previous_semester;
}
$field = 'name';
if (Config::get()->IMPORTANT_SEMNUMBER) {
$field = "veranstaltungsnummer,{$field}";
......
......@@ -116,6 +116,27 @@ class Semester extends SimpleORMap
return null;
}
/**
* Returns the previous semester for a semester specified by a timestamp.
* If no timestamp is specified, the previous semester of the current semester is returned.
*
* @param integer|null $timestamp The timestamp of the semester whose predecessor
* shall be found. Defaults to null.
*
* @return null|Semester A previous semester to the specified one or null, if no such semester
* could be found.
*/
public static function findPrevious($timestamp = null)
{
$timestamp = $timestamp ?: time();
$semester = self::findByTimestamp($timestamp);
if ($semester) {
return self::findByTimestamp((int)$semester->beginn - 1);
}
return null;
}
/**
* returns current Semester
*/
......
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