From 635c0574dda0757ca09b42f888b1c5188fef182a Mon Sep 17 00:00:00 2001 From: Christoph Ludolf Date: Fri, 6 Oct 2023 10:54:16 +0200 Subject: [PATCH 1/3] 0038146: iCal URL problems --- Services/Calendar/classes/Export/class.ilCalendarExport.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Services/Calendar/classes/Export/class.ilCalendarExport.php b/Services/Calendar/classes/Export/class.ilCalendarExport.php index 74fe5dbe8444..6d0451fcc1c6 100644 --- a/Services/Calendar/classes/Export/class.ilCalendarExport.php +++ b/Services/Calendar/classes/Export/class.ilCalendarExport.php @@ -170,7 +170,10 @@ protected function addCategories(int $remaining_bytes): ilICalWriter } usort($single_appointments, function (ilCalendarEntry $a, ilCalendarEntry $b) { - return $a->getStart() > $b->getStart(); + if($a->getStart() === $b->getStart()) { + return 0; + } + return $a->getStart() > $b->getStart() ? 1 : -1; }); // Apply a filter on limited exports only From ac409a67911b43c3d2d846d28eabdc0f41a1dd52 Mon Sep 17 00:00:00 2001 From: Christoph Ludolf Date: Fri, 6 Oct 2023 11:07:32 +0200 Subject: [PATCH 2/3] Fixed missing return type --- .../classes/Export/class.ilCalendarExport.php | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Services/Calendar/classes/Export/class.ilCalendarExport.php b/Services/Calendar/classes/Export/class.ilCalendarExport.php index 6d0451fcc1c6..2c8afe94b338 100644 --- a/Services/Calendar/classes/Export/class.ilCalendarExport.php +++ b/Services/Calendar/classes/Export/class.ilCalendarExport.php @@ -168,41 +168,41 @@ protected function addCategories(int $remaining_bytes): ilICalWriter } $single_appointments[] = $appointment; } + } - usort($single_appointments, function (ilCalendarEntry $a, ilCalendarEntry $b) { - if($a->getStart() === $b->getStart()) { - return 0; - } - return $a->getStart() > $b->getStart() ? 1 : -1; - }); - - // Apply a filter on limited exports only - if ($this->is_export_limited) { - $single_appointments = array_filter($single_appointments, function (ilCalendarEntry $a) { - $time_now = new ilDateTime(time(), IL_CAL_UNIX); - $str_time_now = $time_now->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC); - $str_time_start = $a->getStart()->get(IL_CAL_FKT_DATE, 'Ymd', $this->il_user->getTimeZone()); - $start = new DateTimeImmutable($str_time_start); - $now = new DateTimeImmutable($str_time_now); - $lower_bound = $now->sub(new DateInterval('P30D')); - return $lower_bound <= $start; - }); + usort($single_appointments, function (ilCalendarEntry $a, ilCalendarEntry $b) { + if($a->getStart() === $b->getStart()) { + return 0; } + return $a->getStart() > $b->getStart() ? 1 : -1; + }); + + // Apply a filter on limited exports only + if ($this->is_export_limited) { + $single_appointments = array_filter($single_appointments, function (ilCalendarEntry $a) { + $time_now = new ilDateTime(time(), IL_CAL_UNIX); + $str_time_now = $time_now->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC); + $str_time_start = $a->getStart()->get(IL_CAL_FKT_DATE, 'Ymd', $this->il_user->getTimeZone()); + $start = new DateTimeImmutable($str_time_start); + $now = new DateTimeImmutable($str_time_now); + $lower_bound = $now->sub(new DateInterval('P30D')); + return $lower_bound <= $start; + }); + } - foreach ($single_appointments as $appointment) { - $str_writer_appointment = $this->createAppointment($appointment); - // Check byte count for limited exports only - if ( - $this->is_export_limited && - ($str_writer_appointments->byteCount() + $str_writer_appointment->byteCount()) > $remaining_bytes - ) { - break; - } - $str_writer_appointments->append($str_writer_appointment); + foreach ($single_appointments as $appointment) { + $str_writer_appointment = $this->createAppointment($appointment); + // Check byte count for limited exports only + if ( + $this->is_export_limited && + ($str_writer_appointments->byteCount() + $str_writer_appointment->byteCount()) > $remaining_bytes + ) { + break; } - - return $str_writer_appointments; + $str_writer_appointments->append($str_writer_appointment); } + + return $str_writer_appointments; } protected function isRepeatingAppointment(ilCalendarEntry $appointment): bool From f60bbf38b5ddacfde9c9fcc6fe7fc6c4f06b54c1 Mon Sep 17 00:00:00 2001 From: Christoph Ludolf Date: Fri, 6 Oct 2023 11:10:52 +0200 Subject: [PATCH 3/3] fixed type error --- Services/Calendar/classes/Export/class.ilCalendarExport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Services/Calendar/classes/Export/class.ilCalendarExport.php b/Services/Calendar/classes/Export/class.ilCalendarExport.php index 2c8afe94b338..00de292cda85 100644 --- a/Services/Calendar/classes/Export/class.ilCalendarExport.php +++ b/Services/Calendar/classes/Export/class.ilCalendarExport.php @@ -214,7 +214,7 @@ protected function addAppointments(): ilICalWriter { $str_builder_appointments = new ilICalWriter(); foreach ($this->getAppointments() as $app) { - $str_writer_appointment = $this->createAppointment($app); + $str_writer_appointment = $this->createAppointment(new ilCalendarEntry($app)); $str_builder_appointments->append($str_writer_appointment); } return $str_builder_appointments;