From 02df49692e0fbc92e1f96078f0d0962ac6df0a18 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 27 Jan 2023 07:21:41 +0000 Subject: [PATCH] only select distinct courses in Course::findByUser(), fixes #2086 Closes #2086 Merge request studip/studip!1350 --- lib/models/Course.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php index 4500daa59e8..d9325b099be 100644 --- a/lib/models/Course.class.php +++ b/lib/models/Course.class.php @@ -935,7 +935,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe * @param bool $with_deputies Whether to include courses where the user is * a deputy (true) or not (false). Defaults to true. * - * @returns Course[] A list of courses. + * @return Course[] A list of courses. */ public static function findByUser($user_id, $perms = [], $with_deputies = true) { @@ -960,6 +960,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe return Course::findBySQL( "LEFT JOIN semester_courses ON (semester_courses.course_id = seminare.Seminar_id) WHERE Seminar_id IN (?) + GROUP BY seminare.Seminar_id ORDER BY IF(semester_courses.semester_id IS NULL, 1, 0) DESC, start_time DESC, Name ASC", [$seminar_ids] ); -- GitLab