ILIAS  release_8 Revision v8.24
VEvent.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
23final class VEvent
24{
29 private string $uid;
30 private string $description;
31 private string $summary;
36 private int $sequence;
42 private string $status;
43 private string $organiserName;
44 private string $organiserEmail;
45 private string $attendeeName;
46 private string $attendeeEmail;
47 private int $startTime;
48 private int $endTime;
49 private bool $allDay;
50 private string $url;
51 private string $location;
52
70 public function __construct(
71 string $uid,
72 string $description,
73 string $summary,
74 int $sequence,
75 string $status,
76 string $organiserName,
77 string $organiserEmail,
78 string $attendeeName,
79 string $attendeeEmail,
80 int $startTime,
81 int $endTime,
82 bool $allDay,
83 string $url,
84 string $location
85 ) {
86 $this->uid = $uid;
87 $this->description = $description;
88 $this->summary = $summary;
89 $this->sequence = $sequence;
90 $this->status = $status;
91 $this->organiserName = $organiserName;
92 $this->organiserEmail = $organiserEmail;
93 $this->attendeeName = $attendeeName;
94 $this->attendeeEmail = $attendeeEmail;
95 $this->startTime = $startTime;
96 $this->endTime = $endTime;
97 $this->allDay = $allDay;
98 $this->url = $url;
99 $this->location = $location;
100 }
101
102 private function getStartAndEnd(): string
103 {
104 // creating DateTimes from Unix timestamps automatically sets the initial timezone to UTC
105 $start = new \DateTimeImmutable('@' . $this->startTime);
106 $start = $start->setTimezone(new \DateTimeZone('Europe/Paris'));
107 $end = new \DateTimeImmutable('@' . $this->endTime);
108 $end = $end->setTimezone(new \DateTimeZone('Europe/Paris'));
109
110 if ($this->allDay) {
111 return 'DTSTART;TZID=Europe/Paris;VALUE=DATE:' . $start->format('Ymd') . "\r\n" .
112 'DTEND;TZID=Europe/Paris;VALUE=DATE:' . $end->format('Ymd') . "\r\n" .
113 "X-MICROSOFT-CDO-ALLDAYEVENT: TRUE\r\n";
114 } else {
115 return 'DTSTART;TZID=Europe/Paris:' . $start->format('Ymd\THis') . "\r\n" .
116 'DTEND;TZID=Europe/Paris:' . $end->format('Ymd\THis') . "\r\n";
117 }
118 }
119
120 public function render(): string
121 {
122 return 'BEGIN:VEVENT' . "\r\n" .
123 'UID: ' . $this->uid . "\r\n" .
124 'DESCRIPTION:' . $this->description . "\r\n" .
125 $this->getStartAndEnd() .
126 'DTSTAMP:' . date("Ymd\THis") . "\r\n" .
127 'LAST-MODIFIED:' . date("Ymd\THis") . "\r\n" .
128 'ORGANIZER;CN="' . $this->organiserName . '":MAILTO:' . $this->organiserEmail . "\r\n" .
129 'ATTENDEE;CN="' . $this->attendeeName . '";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:' . $this->attendeeEmail . "\r\n" .
130 'SUMMARY:' . $this->summary . "\r\n" .
131 'LOCATION:' . $this->location . "\r\n" .
132 'SEQUENCE:' . $this->sequence . "\r\n" .
133 "PRIORITY:5\r\n" .
134 'STATUS:' . $this->status . "\r\n" .
135 "TRANSP:OPAQUE\r\n" .
136 "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\r\n" .
137 'CLASS:PUBLIC' . "\r\n" .
138 "X-MICROSOFT-DISALLOW-COUNTER:TRUE\r\n" .
139 //'URL:'. $this->url . "\r\n" .
140
141 'BEGIN:VALARM' . "\r\n" .
142 'DESCRIPTION:' . $this->summary . "\r\n" .
143 'TRIGGER:-PT15M' . "\r\n" .
144 'ACTION:DISPLAY' . "\r\n" .
145 'END:VALARM' . "\r\n" .
146
147 'END:VEVENT' . "\r\n";
148 }
149}
__construct(string $uid, string $description, string $summary, int $sequence, string $status, string $organiserName, string $organiserEmail, string $attendeeName, string $attendeeEmail, int $startTime, int $endTime, bool $allDay, string $url, string $location)
VEvent constructor.
Definition: VEvent.php:70
string $uid
Unique id of the event.
Definition: VEvent.php:29
int $sequence
Must be higher then the previous one, or the cal client will ignore the change.
Definition: VEvent.php:36
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...