diff options
| author | André Noack <noack@data-quest.de> | 2025-04-04 14:26:43 +0000 |
|---|---|---|
| committer | André Noack <noack@data-quest.de> | 2025-04-04 14:26:43 +0000 |
| commit | c9ee32fe7082b5ebe6b17b2ecbe017f7eec8dbd2 (patch) | |
| tree | 56e28b4fe0e6426ce47c84390b317cfb34744c03 | |
| parent | b4e41059251b6184f368b742e7ff2e9fcf9149df (diff) | |
Resolve "Viele DB Anfragen an (ex_)termine im Profil"
Closes #5419
Merge request studip/studip!4102
| -rw-r--r-- | app/controllers/calendar/contentbox.php | 54 | ||||
| -rw-r--r-- | app/views/calendar/contentbox/_termin.php | 4 |
2 files changed, 21 insertions, 37 deletions
diff --git a/app/controllers/calendar/contentbox.php b/app/controllers/calendar/contentbox.php index 54717b4..266ab20 100644 --- a/app/controllers/calendar/contentbox.php +++ b/app/controllers/calendar/contentbox.php @@ -111,42 +111,26 @@ class Calendar_ContentboxController extends StudipController $this->termine = []; + if ($GLOBALS['user']->id === $id) { - //The current user is looking at their dates. - //Get course dates, too: - $relevant_courses = Course::findBySQL( - "JOIN `seminar_user` USING (`seminar_id`) - WHERE `user_id` = :user_id", - ['user_id' => $id] - ); - foreach ($relevant_courses as $course) { - $course_dates = $course->getDatesWithExdates($this->start, $this->start + $this->timespan); - foreach ($course_dates as $course_date) { - //Check if the date belongs to a regular course date and if that is - //made invisible via the schedule: - $show_date = true; - if (!empty($course_date->cycle)) { - $show_date = ScheduleCourseDate::countBySql( - "`user_id` = :user_id - AND `course_id` = :course_id - AND `metadate_id` = :metadate_id - AND `visible` = '0'", - [ - 'user_id' => $id, - 'course_id' => $course_date->range_id, - 'metadate_id' => $course_date->metadate_id - ] - ) === 0; - } - if ($show_date) { - $this->titles[$course_date->id] = sprintf( - '%1$s: %2$s', - $course_date->course->name, - $course_date->getFullName() - ); - $this->termine[] = $course_date; - } - } + $course_dates = CalendarCourseDate::getEvents($begin, $end, $id); + foreach ($course_dates as $course_date) { + $this->titles[$course_date->id] = sprintf( + '%1$s: %2$s', + $course_date->course->name, + $course_date->getFullName() + ); + $this->termine[] = $course_date; + + } + $cancelled_course_dates = CalendarCourseExDate::getEvents($begin, $end, $id); + foreach ($cancelled_course_dates as $cancelled_course_date) { + $this->titles[$cancelled_course_date->id] = sprintf( + '%1$s: %2$s', + $cancelled_course_date->course->name, + $cancelled_course_date->getFullName() + ); + $this->termine[] = $cancelled_course_date; } } diff --git a/app/views/calendar/contentbox/_termin.php b/app/views/calendar/contentbox/_termin.php index d1307b6..b6334e0 100644 --- a/app/views/calendar/contentbox/_termin.php +++ b/app/views/calendar/contentbox/_termin.php @@ -35,7 +35,7 @@ <?= Icon::create('edit')->asImg(['class' => 'text-bottom']) ?> </a> <? endif ?> - <? elseif (!$course_range && in_array($termin->getObjectClass(), ['CourseDate', 'CourseExDate'])) : ?> + <? elseif (!$course_range && in_array($termin->getObjectClass(), [CalendarCourseDate::class, CalendarCourseExDate::class])) : ?> <a href="<?= URLHelper::getLink('dispatch.php/course/dates', ['cid' => $termin->getPrimaryObjectId()]) ?>" title="<?= _('Zur Veranstaltung') ?>" aria-label="<?= _('Zur Veranstaltung') ?>"> <?= Icon::create('seminar')->asImg(['class'=> 'text-bottom']) ?> @@ -88,7 +88,7 @@ <? endif ?> <? endforeach ?> </ul> - <? if (!$course_range && in_array($termin->getObjectClass(), [CourseDate::class, CourseExDate::class])) : ?> + <? if (!$course_range && in_array($termin->getObjectClass(), [CalendarCourseDate::class, CalendarCourseExDate::class])) : ?> <div> <a href="<?= URLHelper::getLink('dispatch.php/course/dates', ['cid' => $termin->getPrimaryObjectId()]) ?>"> <?= Icon::create('link-intern')->asImg(['class'=> 'text-bottom']) ?> |
