From e2d8e70f6b485a006124a420dc7d3232d52ad403 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Fri, 20 May 2022 14:55:04 +0000 Subject: [PATCH] add short_name property to Semester class, fixes #1071 Closes #1071 Merge request studip/studip!650 --- app/controllers/shared/download.php | 4 ++-- app/views/admin/semester/index.php | 2 +- lib/classes/globalsearch/GlobalSearchCourses.php | 2 +- lib/classes/globalsearch/GlobalSearchMyCourses.php | 2 +- lib/models/Course.class.php | 4 ++-- lib/models/Semester.class.php | 3 +++ 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/shared/download.php b/app/controllers/shared/download.php index 39fc7ddae1a..59b17512687 100644 --- a/app/controllers/shared/download.php +++ b/app/controllers/shared/download.php @@ -86,7 +86,7 @@ class Shared_DownloadController extends AuthenticatedController $this->exportTcpdf($blocks, self::sanitizeFilename( _('Modulhandbuch'), trim($this->StgteilVersion->studiengangteil->getDisplayName()), - $semester->semester_token ?: $semester->name, + $semester->short_name, $language )); } @@ -280,4 +280,4 @@ class Shared_DownloadController extends AuthenticatedController } return $result; } -} \ No newline at end of file +} diff --git a/app/views/admin/semester/index.php b/app/views/admin/semester/index.php index c6aeb815ce9..2ac8559a8df 100644 --- a/app/views/admin/semester/index.php +++ b/app/views/admin/semester/index.php @@ -59,7 +59,7 @@ <? endif; ?> </td> <td> - <?= htmlReady($semester->semester_token ?: '- ' . _('keins') . ' -') ?> + <?= htmlReady((string) $semester->semester_token ?: '- ' . _('keins') . ' -') ?> </td> <td> <?= strftime('%x', $semester->beginn) ?> diff --git a/lib/classes/globalsearch/GlobalSearchCourses.php b/lib/classes/globalsearch/GlobalSearchCourses.php index 5ba8e44b610..b4b9bccae1f 100644 --- a/lib/classes/globalsearch/GlobalSearchCourses.php +++ b/lib/classes/globalsearch/GlobalSearchCourses.php @@ -203,7 +203,7 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull 'number' => self::mark($course->veranstaltungsnummer, $search), 'name' => self::mark($course->getFullname(), $search), 'url' => URLHelper::getURL("dispatch.php/course/details/index/{$course->id}", [], true), - 'date' => (string) $semester->token ?: (string) $semester->name, + 'date' => $semester->short_name, 'dates' => $turnus_string, 'has_children' => count($course->children) > 0, 'children' => $result_children, diff --git a/lib/classes/globalsearch/GlobalSearchMyCourses.php b/lib/classes/globalsearch/GlobalSearchMyCourses.php index 5a0ac188284..a058b0b4c30 100644 --- a/lib/classes/globalsearch/GlobalSearchMyCourses.php +++ b/lib/classes/globalsearch/GlobalSearchMyCourses.php @@ -145,7 +145,7 @@ class GlobalSearchMyCourses extends GlobalSearchModule 'number' => self::mark($course->veranstaltungsnummer, $search), 'name' => self::mark($course->getFullname(), $search), 'url' => URLHelper::getURL('seminar_main.php', ['cid' => $course->id], true), - 'date' => (string) $semester->token ?: (string) $semester->name, + 'date' => $semester->short_name, 'dates' => $turnus_string, 'has_children' => count($course->children) > 0, 'children' => $result_children, diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php index 878c12edbf4..ba36ee9fb90 100644 --- a/lib/models/Course.class.php +++ b/lib/models/Course.class.php @@ -392,9 +392,9 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe public function getTextualSemester() { if (count($this->semesters) > 1) { - return $this->start_semester->name . ' - ' . $this->end_semester->name; + return $this->start_semester->short_name . ' - ' . $this->end_semester->short_name; } elseif (count($this->semesters) === 1) { - return $this->start_semester->name; + return $this->start_semester->short_name; } else { return _('unbegrenzt'); } diff --git a/lib/models/Semester.class.php b/lib/models/Semester.class.php index a5d81c7ca85..33b309895d0 100644 --- a/lib/models/Semester.class.php +++ b/lib/models/Semester.class.php @@ -41,6 +41,9 @@ class Semester extends SimpleORMap $config['additional_fields']['last_sem_week']['get'] = 'getLastSemesterWeek'; $config['additional_fields']['current']['get'] = 'isCurrent'; $config['additional_fields']['past']['get'] = 'isPast'; + $config['additional_fields']['short_name']['get'] = function($semester) { + return (string) $semester->semester_token ?: (string) $semester->name; + }; $config['additional_fields']['absolute_seminars_count'] = [ 'get' => 'seminarCounter', -- GitLab