From b660294ce9eb76cf91ab0613b2077c62a38672d0 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Mon, 18 Mar 2024 16:04:16 +0100
Subject: [PATCH] reverted changes from StEP #1354 in
 lib/modules/ScheduleWidget.php

---
 lib/modules/ScheduleWidget.php | 42 +++++-----------------------------
 1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/lib/modules/ScheduleWidget.php b/lib/modules/ScheduleWidget.php
index 0393176827d..339beb3f87f 100644
--- a/lib/modules/ScheduleWidget.php
+++ b/lib/modules/ScheduleWidget.php
@@ -39,45 +39,15 @@ class ScheduleWidget extends CorePlugin implements PortalPlugin
      */
     public function getPortalTemplate()
     {
-        $week_slot_duration = \Studip\Calendar\Helper::getCalendarSlotDuration('week');
-        $calendar_settings = $GLOBALS['user']->cfg->CALENDAR_SETTINGS ?? [];
-
-        $semester = Semester::findCurrent();
-        $fullcalendar = \Studip\Fullcalendar::create(
-            '',
-            [
-                'minTime' => '08:00',
-                'maxTime' => '20:00',
-                'allDaySlot' => false,
-                'header' => [
-                    'left' => '',
-                    'right' => ''
-                ],
-                'views' => [
-                    'timeGridWeek' => [
-                        'columnHeaderFormat' => ['weekday' => 'long'],
-                        'weekends'           => $calendar_settings['type_week'] === 'LONG',
-                        'slotDuration'       => $week_slot_duration
-                    ]
-                ],
-                'defaultView' => 'timeGridWeek',
-                'defaultDate' => date('Y-m-d'),
-                'timeGridEventMinHeight' => 20,
-                'eventSources' => [
-                    [
-                        'url' => URLHelper::getURL('dispatch.php/calendar/calendar/schedule_data'),
-                        'method' => 'GET',
-                        'extraParams' => [
-                            'semester_id' => $semester->id,
-                            'full_semester_time_range' => false
-                        ]
-                    ]
-                ]
-            ]
+        $view = CalendarScheduleModel::getUserCalendarView(
+            $GLOBALS['user']->id,
+            false,
+            false,
+            $days = array(0,1,2,3,4)
         );
 
         $template = $GLOBALS['template_factory']->open('shared/string');
-        $template->content = $fullcalendar;
+        $template->content = CalendarWidgetView::createFromWeekView($view)->render();
 
         return $template;
     }
-- 
GitLab