diff --git a/includes/Functions.php b/includes/Functions.php index ee55e79..93a8e74 100644 --- a/includes/Functions.php +++ b/includes/Functions.php @@ -8,6 +8,12 @@ class Functions { + + public static function formatDateGMT($timestamp){ + $date = new \DateTime(get_gmt_from_date(date('Y-m-d H:i:s', $timestamp))); + return $date->format('Ymd\THis\Z'); + } + public static function dateFormat(int $timestamp): string { return date_i18n(get_option('date_format'), $timestamp); diff --git a/includes/ICS.php b/includes/ICS.php index 597e2c9..e425fce 100644 --- a/includes/ICS.php +++ b/includes/ICS.php @@ -17,56 +17,32 @@ public static function generate(array &$booking, string $filename, string $recip $output .= "BEGIN:VCALENDAR\r\n"; $output .= "VERSION:2.0\r\n"; $output .= "PRODID:-//rrze//rsvp//EN\r\n"; - $output .= "CALSCALE:GREGORIAN\r\n"; - $output .= "BEGIN:VTIMEZONE\r\n"; - $output .= "TZID:Europe/Berlin\r\n"; - $output .= "TZURL:http://tzurl.org/zoneinfo-outlook/Europe/Berlin\r\n"; - $output .= "X-LIC-LOCATION:Europe/Berlin\r\n"; - $output .= "BEGIN:DAYLIGHT\r\n"; - $output .= "TZOFFSETFROM:+0100\r\n"; - $output .= "TZOFFSETTO:+0200\r\n"; - $output .= "TZNAME:CEST\r\n"; - $output .= "DTSTART:19700329T020000\r\n"; - $output .= "RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\n"; - $output .= "END:DAYLIGHT\r\n"; - $output .= "BEGIN:STANDARD\r\n"; - $output .= "TZOFFSETFROM:+0200\r\n"; - $output .= "TZOFFSETTO:+0100\r\n"; - $output .= "TZNAME:CET\r\n"; - $output .= "DTSTART:19701025T030000\r\n"; - $output .= "RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\n"; - $output .= "END:STANDARD\r\n"; - $output .= "END:VTIMEZONE\r\n"; $output .= self::vevent($booking, $recipient); $output .= "END:VCALENDAR\r\n"; return $output; } - protected static function vevent(array &$booking, string $recipient = 'customer'): string - { - // $timezoneString = get_option('timezone_string'); - $timezoneString = 'Europe/Berlin'; - $dtstamp = date('Ymd\THis'); + protected static function vevent(array &$booking, string $recipient = 'customer'): string { + $dtstamp = Functions::formatDateGMT(time()); $dtstampFormat = Functions::dateFormat(current_time('timestamp')) . ' ' . Functions::timeFormat(current_time('timestamp')); - $timestamp = date('ymdHi', $booking['start']); - $dtstamp = date('Ymd\THis'); - $dtstart = date('Ymd\THis', $booking['start']); - $dtend = date('Ymd\THis', $booking['end']); + $dtstart = Functions::formatDateGMT($booking['start']); + $dtend = Functions::formatDateGMT($booking['end']); $summary = $booking['room_name']; - $description = $booking['room_name'] . '\\n'; $description .= !empty($booking['seat_name']) ? $booking['seat_name'] . '\\n' : ''; + if ($recipient == 'customer') { $cancelUrl = Functions::bookingReplyUrl('cancel', sprintf('%s-%s-customer', $booking['id'], $booking['start']), $booking['id']); $description .= "\\n\\n" . __('Cancel Booking', 'rrze-rsvp') . ':\\n' . $cancelUrl; } + $description .= "\\n\\n" . __('Generated', 'rrze-rsvp') . ': ' . $dtstampFormat; $output = ''; - $output .= "BEGIN:VEVENT\r\n"; + if ($booking['status'] == 'cancelled'){ $output .= "METHOD:CANCEL\r\n"; $output .= "STATUS:CANCELLED\r\n"; @@ -75,10 +51,11 @@ protected static function vevent(array &$booking, string $recipient = 'customer' $uid = md5($timestamp . date('ymdHi')) . "@rrze-rsvp"; update_post_meta($booking['id'], 'rrze-rsvp-booking-ics-uid', $uid); } + $output .= "UID:" . $uid . "\r\n"; $output .= "DTSTAMP:" . $dtstamp . "\r\n"; - $output .= "DTSTART;TZID=" . $timezoneString . ":" . $dtstart . "\r\n"; - $output .= "DTEND;TZID=" . $timezoneString . ":" . $dtend . "\r\n"; + $output .= "DTSTART:" . $dtstart . "\r\n"; + $output .= "DTEND:" . $dtend . "\r\n"; $output .= "SUMMARY:" . $summary . "\r\n"; $output .= "DESCRIPTION:" . $description . "\r\n"; $output .= "END:VEVENT\r\n"; diff --git a/package.json b/package.json index aa266fd..adb134f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rrze-rsvp", - "version": "2.6.23", + "version": "2.6.24", "description": "Platzbuchungssystem der FAU.", "main": "rrze-rsvp.php", "textdomain": "rrze-rsvp", diff --git a/rrze-rsvp.php b/rrze-rsvp.php index e9cdee9..e5940b5 100644 --- a/rrze-rsvp.php +++ b/rrze-rsvp.php @@ -4,7 +4,7 @@ Plugin Name: RRZE RSVP Plugin URI: https://github.com/RRZE-Webteam/rrze-rsvp Description: FAU Reservation Tool -Version: 2.6.23 +Version: 2.6.24 Author: RRZE-Webteam Author URI: https://blogs.fau.de/webworking/ License: GNU General Public License v2