Skip to content

Commit

Permalink
2.6.24 ( #301 )
Browse files Browse the repository at this point in the history
  • Loading branch information
thenickless committed Oct 7, 2021
1 parent 6daad35 commit 89a2c9a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 35 deletions.
6 changes: 6 additions & 0 deletions includes/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
43 changes: 10 additions & 33 deletions includes/ICS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion rrze-rsvp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 89a2c9a

Please sign in to comment.