1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the eluceo/iCal package. |
5
|
|
|
* |
6
|
|
|
* (c) Markus Poerschke <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Eluceo\iCal\Component; |
13
|
|
|
|
14
|
|
|
use Eluceo\iCal\Component; |
15
|
|
|
use Eluceo\iCal\Property; |
16
|
|
|
use Eluceo\iCal\Property\DateTimeProperty; |
17
|
|
|
use Eluceo\iCal\Property\DateTimesProperty; |
18
|
|
|
use Eluceo\iCal\Property\Event\Attachment; |
19
|
|
|
use Eluceo\iCal\Property\Event\Attendees; |
20
|
|
|
use Eluceo\iCal\Property\Event\Geo; |
21
|
|
|
use Eluceo\iCal\Property\Event\Organizer; |
22
|
|
|
use Eluceo\iCal\Property\Event\RecurrenceId; |
23
|
|
|
use Eluceo\iCal\Property\Event\RecurrenceRule; |
24
|
|
|
use Eluceo\iCal\Property\RawStringValue; |
25
|
|
|
use Eluceo\iCal\PropertyBag; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Implementation of the EVENT component. |
29
|
|
|
*/ |
30
|
|
|
class Event extends Component |
31
|
|
|
{ |
32
|
|
|
const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE'; |
33
|
|
|
const TIME_TRANSPARENCY_TRANSPARENT = 'TRANSPARENT'; |
34
|
|
|
|
35
|
|
|
const STATUS_TENTATIVE = 'TENTATIVE'; |
36
|
|
|
const STATUS_CONFIRMED = 'CONFIRMED'; |
37
|
|
|
const STATUS_CANCELLED = 'CANCELLED'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $uniqueId; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The property indicates the date/time that the instance of |
46
|
|
|
* the iCalendar object was created. |
47
|
|
|
* |
48
|
|
|
* The value MUST be specified in the UTC time format. |
49
|
|
|
* |
50
|
|
|
* @var \DateTime |
51
|
|
|
*/ |
52
|
|
|
protected $dtStamp; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var \DateTime |
56
|
|
|
*/ |
57
|
|
|
protected $dtStart; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Preferentially chosen over the duration if both are set. |
61
|
|
|
* |
62
|
|
|
* @var \DateTime |
63
|
|
|
*/ |
64
|
|
|
protected $dtEnd; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var \DateInterval |
68
|
|
|
*/ |
69
|
|
|
protected $duration; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var bool |
73
|
|
|
*/ |
74
|
|
|
protected $noTime = false; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var string |
78
|
|
|
*/ |
79
|
|
|
protected $url; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var string |
83
|
|
|
*/ |
84
|
|
|
protected $location; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var string |
88
|
|
|
*/ |
89
|
|
|
protected $locationTitle; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var Geo |
93
|
|
|
*/ |
94
|
|
|
protected $locationGeo; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @var string |
98
|
|
|
*/ |
99
|
|
|
protected $summary; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @var Organizer |
103
|
|
|
*/ |
104
|
|
|
protected $organizer; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @see https://tools.ietf.org/html/rfc5545#section-3.8.2.7 |
108
|
|
|
* |
109
|
|
|
* @var string |
110
|
|
|
*/ |
111
|
|
|
protected $transparency = self::TIME_TRANSPARENCY_OPAQUE; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* If set to true the timezone will be added to the event. |
115
|
|
|
* |
116
|
|
|
* @var bool |
117
|
|
|
*/ |
118
|
|
|
protected $useTimezone = false; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* If set will be used as the timezone identifier. |
122
|
|
|
* |
123
|
|
|
* @var string |
124
|
|
|
*/ |
125
|
|
|
protected $timezoneString = ''; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @var int |
129
|
|
|
*/ |
130
|
|
|
protected $sequence = 0; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @var Attendees |
134
|
|
|
*/ |
135
|
|
|
protected $attendees; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @var string |
139
|
|
|
*/ |
140
|
|
|
protected $description; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @var string |
144
|
|
|
*/ |
145
|
|
|
protected $descriptionHTML; |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @var string |
149
|
|
|
*/ |
150
|
|
|
protected $status; |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @var RecurrenceRule |
154
|
|
|
*/ |
155
|
|
|
protected $recurrenceRule; |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @var array |
159
|
|
|
*/ |
160
|
|
|
protected $recurrenceRules = []; |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* This property specifies the date and time that the calendar |
164
|
|
|
* information was created. |
165
|
|
|
* |
166
|
|
|
* The value MUST be specified in the UTC time format. |
167
|
|
|
* |
168
|
|
|
* @var \DateTime |
169
|
|
|
*/ |
170
|
|
|
protected $created; |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* The property specifies the date and time that the information |
174
|
|
|
* associated with the calendar component was last revised. |
175
|
|
|
* |
176
|
|
|
* The value MUST be specified in the UTC time format. |
177
|
|
|
* |
178
|
|
|
* @var \DateTime |
179
|
|
|
*/ |
180
|
|
|
protected $modified; |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Indicates if the UTC time should be used or not. |
184
|
|
|
* |
185
|
|
|
* @var bool |
186
|
|
|
*/ |
187
|
|
|
protected $useUtc = true; |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @var bool |
191
|
|
|
*/ |
192
|
|
|
protected $cancelled; |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* This property is used to specify categories or subtypes |
196
|
|
|
* of the calendar component. The categories are useful in searching |
197
|
|
|
* for a calendar component of a particular type and category. |
198
|
|
|
* |
199
|
|
|
* @see https://tools.ietf.org/html/rfc5545#section-3.8.1.2 |
200
|
|
|
* |
201
|
|
|
* @var array |
202
|
|
|
*/ |
203
|
|
|
protected $categories; |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* https://tools.ietf.org/html/rfc5545#section-3.8.1.3. |
207
|
|
|
* |
208
|
|
|
* @var bool |
209
|
|
|
*/ |
210
|
|
|
protected $isPrivate = false; |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Dates to be excluded from a series of events. |
214
|
|
|
* |
215
|
|
|
* @var \DateTimeInterface[] |
216
|
|
|
*/ |
217
|
|
|
protected $exDates = []; |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @var RecurrenceId |
221
|
|
|
*/ |
222
|
|
|
protected $recurrenceId; |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @var Attachment[] |
226
|
|
|
*/ |
227
|
|
|
protected $attachments = []; |
228
|
|
|
|
229
|
26 |
|
public function __construct(string $uniqueId = null) |
230
|
|
|
{ |
231
|
26 |
|
if (null == $uniqueId) { |
|
|
|
|
232
|
4 |
|
$uniqueId = uniqid(); |
233
|
|
|
} |
234
|
|
|
|
235
|
26 |
|
$this->uniqueId = $uniqueId; |
236
|
26 |
|
$this->attendees = new Attendees(); |
237
|
26 |
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* {@inheritdoc} |
241
|
|
|
*/ |
242
|
7 |
|
public function getType() |
243
|
|
|
{ |
244
|
7 |
|
return 'VEVENT'; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* {@inheritdoc} |
249
|
|
|
*/ |
250
|
17 |
|
public function buildPropertyBag() |
251
|
|
|
{ |
252
|
17 |
|
$propertyBag = new PropertyBag(); |
253
|
|
|
|
254
|
|
|
// mandatory information |
255
|
17 |
|
$propertyBag->set('UID', $this->uniqueId); |
256
|
|
|
|
257
|
17 |
|
$propertyBag->add(new DateTimeProperty('DTSTART', $this->dtStart, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString)); |
258
|
17 |
|
$propertyBag->set('SEQUENCE', $this->sequence); |
259
|
17 |
|
$propertyBag->set('TRANSP', $this->transparency); |
260
|
|
|
|
261
|
17 |
|
if ($this->status) { |
262
|
|
|
$propertyBag->set('STATUS', $this->status); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
// An event can have a 'dtend' or 'duration', but not both. |
266
|
17 |
|
if ($this->dtEnd !== null) { |
267
|
4 |
|
$dtEnd = clone $this->dtEnd; |
268
|
4 |
|
if ($this->noTime === true) { |
269
|
|
|
$dtEnd = $dtEnd->add(new \DateInterval('P1D')); |
270
|
|
|
} |
271
|
4 |
|
$propertyBag->add(new DateTimeProperty('DTEND', $dtEnd, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString)); |
272
|
13 |
|
} elseif ($this->duration !== null) { |
273
|
1 |
|
$propertyBag->set('DURATION', $this->duration->format('P%dDT%hH%iM%sS')); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
// optional information |
277
|
17 |
|
if (null != $this->url) { |
278
|
1 |
|
$propertyBag->set('URL', $this->url); |
279
|
|
|
} |
280
|
|
|
|
281
|
17 |
|
if (null != $this->location) { |
282
|
2 |
|
$propertyBag->set('LOCATION', $this->location); |
283
|
|
|
|
284
|
2 |
|
if (null != $this->locationGeo) { |
285
|
1 |
|
$propertyBag->add( |
286
|
1 |
|
new Property( |
287
|
1 |
|
'X-APPLE-STRUCTURED-LOCATION', |
288
|
1 |
|
new RawStringValue('geo:' . $this->locationGeo->getGeoLocationAsString(',')), |
289
|
|
|
[ |
290
|
1 |
|
'VALUE' => 'URI', |
291
|
1 |
|
'X-ADDRESS' => $this->location, |
292
|
1 |
|
'X-APPLE-RADIUS' => 49, |
293
|
1 |
|
'X-TITLE' => $this->locationTitle, |
294
|
|
|
] |
295
|
|
|
) |
296
|
|
|
); |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
|
300
|
17 |
|
if (null != $this->locationGeo) { |
301
|
2 |
|
$propertyBag->add($this->locationGeo); |
302
|
|
|
} |
303
|
|
|
|
304
|
17 |
|
if (null != $this->summary) { |
305
|
1 |
|
$propertyBag->set('SUMMARY', $this->summary); |
306
|
|
|
} |
307
|
|
|
|
308
|
17 |
|
if (null != $this->attendees) { |
309
|
17 |
|
$propertyBag->add($this->attendees); |
310
|
|
|
} |
311
|
|
|
|
312
|
17 |
|
$propertyBag->set('CLASS', $this->isPrivate ? 'PRIVATE' : 'PUBLIC'); |
313
|
|
|
|
314
|
17 |
|
if (null != $this->description) { |
315
|
4 |
|
$propertyBag->set('DESCRIPTION', $this->description); |
316
|
|
|
} |
317
|
|
|
|
318
|
17 |
|
if (null != $this->descriptionHTML) { |
319
|
|
|
$propertyBag->add( |
320
|
|
|
new Property( |
321
|
|
|
'X-ALT-DESC', |
322
|
|
|
$this->descriptionHTML, |
323
|
|
|
[ |
324
|
|
|
'FMTTYPE' => 'text/html', |
325
|
|
|
] |
326
|
|
|
) |
327
|
|
|
); |
328
|
|
|
} |
329
|
|
|
|
330
|
17 |
|
if (null != $this->recurrenceRule) { |
331
|
|
|
$propertyBag->set('RRULE', $this->recurrenceRule); |
332
|
|
|
} |
333
|
|
|
|
334
|
17 |
|
foreach ($this->recurrenceRules as $recurrenceRule) { |
335
|
|
|
$propertyBag->set('RRULE', $recurrenceRule); |
336
|
|
|
} |
337
|
|
|
|
338
|
17 |
|
if (null != $this->recurrenceId) { |
339
|
|
|
$this->recurrenceId->applyTimeSettings($this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString); |
340
|
|
|
$propertyBag->add($this->recurrenceId); |
341
|
|
|
} |
342
|
|
|
|
343
|
17 |
|
if (!empty($this->exDates)) { |
344
|
|
|
$propertyBag->add(new DateTimesProperty('EXDATE', $this->exDates, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString)); |
345
|
|
|
} |
346
|
|
|
|
347
|
17 |
|
if ($this->cancelled) { |
348
|
|
|
$propertyBag->set('STATUS', 'CANCELLED'); |
349
|
|
|
} |
350
|
|
|
|
351
|
17 |
|
if (null != $this->organizer) { |
352
|
2 |
|
$propertyBag->add($this->organizer); |
353
|
|
|
} |
354
|
|
|
|
355
|
17 |
|
if ($this->noTime) { |
356
|
1 |
|
$propertyBag->set('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE'); |
357
|
|
|
} |
358
|
|
|
|
359
|
17 |
|
if (null != $this->categories) { |
360
|
|
|
$propertyBag->set('CATEGORIES', $this->categories); |
361
|
|
|
} |
362
|
|
|
|
363
|
17 |
|
$propertyBag->add( |
364
|
17 |
|
new DateTimeProperty('DTSTAMP', $this->dtStamp ?: new \DateTimeImmutable(), false, false, true) |
365
|
|
|
); |
366
|
|
|
|
367
|
17 |
|
if ($this->created) { |
368
|
|
|
$propertyBag->add(new DateTimeProperty('CREATED', $this->created, false, false, true)); |
369
|
|
|
} |
370
|
|
|
|
371
|
17 |
|
if ($this->modified) { |
372
|
|
|
$propertyBag->add(new DateTimeProperty('LAST-MODIFIED', $this->modified, false, false, true)); |
373
|
|
|
} |
374
|
|
|
|
375
|
17 |
|
foreach ($this->attachments as $attachment) { |
376
|
|
|
$propertyBag->add($attachment); |
377
|
|
|
} |
378
|
|
|
|
379
|
17 |
|
return $propertyBag; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* @param $dtEnd |
384
|
|
|
* |
385
|
|
|
* @return $this |
386
|
|
|
*/ |
387
|
5 |
|
public function setDtEnd($dtEnd) |
388
|
|
|
{ |
389
|
5 |
|
$this->dtEnd = $dtEnd; |
390
|
|
|
|
391
|
5 |
|
return $this; |
392
|
|
|
} |
393
|
|
|
|
394
|
2 |
|
public function getDtEnd() |
395
|
|
|
{ |
396
|
2 |
|
return $this->dtEnd; |
397
|
|
|
} |
398
|
|
|
|
399
|
5 |
|
public function setDtStart($dtStart) |
400
|
|
|
{ |
401
|
5 |
|
$this->dtStart = $dtStart; |
402
|
|
|
|
403
|
5 |
|
return $this; |
404
|
|
|
} |
405
|
|
|
|
406
|
2 |
|
public function getDtStart() |
407
|
|
|
{ |
408
|
2 |
|
return $this->dtStart; |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* @param $dtStamp |
413
|
|
|
* |
414
|
|
|
* @return $this |
415
|
|
|
*/ |
416
|
1 |
|
public function setDtStamp($dtStamp) |
417
|
|
|
{ |
418
|
1 |
|
$this->dtStamp = $dtStamp; |
419
|
|
|
|
420
|
1 |
|
return $this; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
/** |
424
|
|
|
* @param $duration |
425
|
|
|
* |
426
|
|
|
* @return $this |
427
|
|
|
*/ |
428
|
1 |
|
public function setDuration($duration) |
429
|
|
|
{ |
430
|
1 |
|
$this->duration = $duration; |
431
|
|
|
|
432
|
1 |
|
return $this; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* @param string $location |
437
|
|
|
* @param string $title |
438
|
|
|
* @param Geo|string $geo |
439
|
|
|
* |
440
|
|
|
* @return $this |
441
|
|
|
*/ |
442
|
3 |
|
public function setLocation($location, $title = '', $geo = null) |
443
|
|
|
{ |
444
|
3 |
|
if (is_scalar($geo)) { |
445
|
1 |
|
$geo = Geo::fromString($geo); |
|
|
|
|
446
|
2 |
|
} elseif (!is_null($geo) && !$geo instanceof Geo) { |
447
|
1 |
|
$className = get_class($geo); |
448
|
1 |
|
throw new \InvalidArgumentException( |
449
|
|
|
"The parameter 'geo' must be a string or an instance of " . Geo::class |
450
|
1 |
|
. " but an instance of {$className} was given." |
451
|
|
|
); |
452
|
|
|
} |
453
|
|
|
|
454
|
2 |
|
$this->location = $location; |
455
|
2 |
|
$this->locationTitle = $title; |
456
|
2 |
|
$this->locationGeo = $geo; |
457
|
|
|
|
458
|
2 |
|
return $this; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* @param Geo $geoProperty |
463
|
|
|
* |
464
|
|
|
* @return $this |
465
|
|
|
*/ |
466
|
1 |
|
public function setGeoLocation(Geo $geoProperty) |
467
|
|
|
{ |
468
|
1 |
|
$this->locationGeo = $geoProperty; |
469
|
|
|
|
470
|
1 |
|
return $this; |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* @param $noTime |
475
|
|
|
* |
476
|
|
|
* @return $this |
477
|
|
|
*/ |
478
|
1 |
|
public function setNoTime($noTime) |
479
|
|
|
{ |
480
|
1 |
|
$this->noTime = $noTime; |
481
|
|
|
|
482
|
1 |
|
return $this; |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* @param int $sequence |
487
|
|
|
* |
488
|
|
|
* @return $this |
489
|
|
|
*/ |
490
|
2 |
|
public function setSequence($sequence) |
491
|
|
|
{ |
492
|
2 |
|
$this->sequence = $sequence; |
493
|
|
|
|
494
|
2 |
|
return $this; |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* @return int |
499
|
|
|
*/ |
500
|
1 |
|
public function getSequence() |
501
|
|
|
{ |
502
|
1 |
|
return $this->sequence; |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* @param Organizer $organizer |
507
|
|
|
* |
508
|
|
|
* @return $this |
509
|
|
|
*/ |
510
|
2 |
|
public function setOrganizer(Organizer $organizer) |
511
|
|
|
{ |
512
|
2 |
|
$this->organizer = $organizer; |
513
|
|
|
|
514
|
2 |
|
return $this; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* @param $summary |
519
|
|
|
* |
520
|
|
|
* @return $this |
521
|
|
|
*/ |
522
|
1 |
|
public function setSummary($summary) |
523
|
|
|
{ |
524
|
1 |
|
$this->summary = $summary; |
525
|
|
|
|
526
|
1 |
|
return $this; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* @param $uniqueId |
531
|
|
|
* |
532
|
|
|
* @return $this |
533
|
|
|
*/ |
534
|
1 |
|
public function setUniqueId($uniqueId) |
535
|
|
|
{ |
536
|
1 |
|
$this->uniqueId = $uniqueId; |
537
|
|
|
|
538
|
1 |
|
return $this; |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
/** |
542
|
|
|
* @return string |
543
|
|
|
*/ |
544
|
2 |
|
public function getUniqueId() |
545
|
|
|
{ |
546
|
2 |
|
return $this->uniqueId; |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* @param $url |
551
|
|
|
* |
552
|
|
|
* @return $this |
553
|
|
|
*/ |
554
|
1 |
|
public function setUrl($url) |
555
|
|
|
{ |
556
|
1 |
|
$this->url = $url; |
557
|
|
|
|
558
|
1 |
|
return $this; |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
/** |
562
|
|
|
* @param $useTimezone |
563
|
|
|
* |
564
|
|
|
* @return $this |
565
|
|
|
*/ |
566
|
|
|
public function setUseTimezone($useTimezone) |
567
|
|
|
{ |
568
|
|
|
$this->useTimezone = $useTimezone; |
569
|
|
|
|
570
|
|
|
return $this; |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
/** |
574
|
|
|
* @return bool |
575
|
|
|
*/ |
576
|
|
|
public function getUseTimezone() |
577
|
|
|
{ |
578
|
|
|
return $this->useTimezone; |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
/** |
582
|
|
|
* @param $timezoneString |
583
|
|
|
* |
584
|
|
|
* @return $this |
585
|
|
|
*/ |
586
|
2 |
|
public function setTimezoneString($timezoneString) |
587
|
|
|
{ |
588
|
2 |
|
$this->timezoneString = $timezoneString; |
589
|
|
|
|
590
|
2 |
|
return $this; |
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
/** |
594
|
|
|
* @return bool |
595
|
|
|
*/ |
596
|
1 |
|
public function getTimezoneString() |
597
|
|
|
{ |
598
|
1 |
|
return $this->timezoneString; |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
/** |
602
|
|
|
* @param Attendees $attendees |
603
|
|
|
* |
604
|
|
|
* @return $this |
605
|
|
|
*/ |
606
|
|
|
public function setAttendees(Attendees $attendees) |
607
|
|
|
{ |
608
|
|
|
$this->attendees = $attendees; |
609
|
|
|
|
610
|
|
|
return $this; |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
/** |
614
|
|
|
* @param string $attendee |
615
|
|
|
* @param array $params |
616
|
|
|
* |
617
|
|
|
* @return $this |
618
|
|
|
*/ |
619
|
|
|
public function addAttendee($attendee, $params = []) |
620
|
|
|
{ |
621
|
|
|
$this->attendees->add($attendee, $params); |
622
|
|
|
|
623
|
|
|
return $this; |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* @return Attendees |
628
|
|
|
*/ |
629
|
|
|
public function getAttendees(): Attendees |
630
|
|
|
{ |
631
|
|
|
return $this->attendees; |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
/** |
635
|
|
|
* @param $description |
636
|
|
|
* |
637
|
|
|
* @return $this |
638
|
|
|
*/ |
639
|
4 |
|
public function setDescription($description) |
640
|
|
|
{ |
641
|
4 |
|
$this->description = $description; |
642
|
|
|
|
643
|
4 |
|
return $this; |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
/** |
647
|
|
|
* @param $descriptionHTML |
648
|
|
|
* |
649
|
|
|
* @return $this |
650
|
|
|
*/ |
651
|
|
|
public function setDescriptionHTML($descriptionHTML) |
652
|
|
|
{ |
653
|
|
|
$this->descriptionHTML = $descriptionHTML; |
654
|
|
|
|
655
|
|
|
return $this; |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* @param bool $useUtc |
660
|
|
|
* |
661
|
|
|
* @return $this |
662
|
|
|
*/ |
663
|
|
|
public function setUseUtc($useUtc = true) |
664
|
|
|
{ |
665
|
|
|
$this->useUtc = $useUtc; |
666
|
|
|
|
667
|
|
|
return $this; |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
/** |
671
|
|
|
* @return string |
672
|
|
|
*/ |
673
|
|
|
public function getDescription() |
674
|
|
|
{ |
675
|
|
|
return $this->description; |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* @return string |
680
|
|
|
*/ |
681
|
|
|
public function getDescriptionHTML() |
682
|
|
|
{ |
683
|
|
|
return $this->descriptionHTML; |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
/** |
687
|
|
|
* @param $status |
688
|
|
|
* |
689
|
|
|
* @return $this |
690
|
|
|
*/ |
691
|
|
|
public function setCancelled($status) |
692
|
|
|
{ |
693
|
|
|
$this->cancelled = (bool) $status; |
694
|
|
|
|
695
|
|
|
return $this; |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
/** |
699
|
|
|
* @param $transparency |
700
|
|
|
* |
701
|
|
|
* @return $this |
702
|
|
|
* |
703
|
|
|
* @throws \InvalidArgumentException |
704
|
|
|
*/ |
705
|
|
View Code Duplication |
public function setTimeTransparency($transparency) |
|
|
|
|
706
|
|
|
{ |
707
|
|
|
$transparency = strtoupper($transparency); |
708
|
|
|
if ($transparency === self::TIME_TRANSPARENCY_OPAQUE |
709
|
|
|
|| $transparency === self::TIME_TRANSPARENCY_TRANSPARENT |
710
|
|
|
) { |
711
|
|
|
$this->transparency = $transparency; |
712
|
|
|
} else { |
713
|
|
|
throw new \InvalidArgumentException('Invalid value for transparancy'); |
714
|
|
|
} |
715
|
|
|
|
716
|
|
|
return $this; |
717
|
|
|
} |
718
|
|
|
|
719
|
|
|
/** |
720
|
|
|
* @param $status |
721
|
|
|
* |
722
|
|
|
* @return $this |
723
|
|
|
* |
724
|
|
|
* @throws \InvalidArgumentException |
725
|
|
|
*/ |
726
|
|
|
public function setStatus($status) |
727
|
|
|
{ |
728
|
|
|
$status = strtoupper($status); |
729
|
|
|
if ($status == self::STATUS_CANCELLED |
730
|
|
|
|| $status == self::STATUS_CONFIRMED |
731
|
|
|
|| $status == self::STATUS_TENTATIVE |
732
|
|
|
) { |
733
|
|
|
$this->status = $status; |
734
|
|
|
} else { |
735
|
|
|
throw new \InvalidArgumentException('Invalid value for status'); |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
return $this; |
739
|
|
|
} |
740
|
|
|
|
741
|
|
|
/** |
742
|
|
|
* @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use addRecurrenceRule instead. |
743
|
|
|
* |
744
|
|
|
* @param RecurrenceRule $recurrenceRule |
745
|
|
|
* |
746
|
|
|
* @return $this |
747
|
|
|
*/ |
748
|
|
|
public function setRecurrenceRule(RecurrenceRule $recurrenceRule) |
749
|
|
|
{ |
750
|
|
|
@trigger_error('setRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use addRecurrenceRule instead.', E_USER_DEPRECATED); |
|
|
|
|
751
|
|
|
|
752
|
|
|
$this->recurrenceRule = $recurrenceRule; |
753
|
|
|
|
754
|
|
|
return $this; |
755
|
|
|
} |
756
|
|
|
|
757
|
|
|
/** |
758
|
|
|
* @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use getRecurrenceRules instead. |
759
|
|
|
* |
760
|
|
|
* @return RecurrenceRule |
761
|
|
|
*/ |
762
|
|
|
public function getRecurrenceRule() |
763
|
|
|
{ |
764
|
|
|
@trigger_error('getRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use getRecurrenceRules instead.', E_USER_DEPRECATED); |
|
|
|
|
765
|
|
|
|
766
|
|
|
return $this->recurrenceRule; |
767
|
|
|
} |
768
|
|
|
|
769
|
|
|
/** |
770
|
|
|
* @param RecurrenceRule $recurrenceRule |
771
|
|
|
* |
772
|
|
|
* @return $this |
773
|
|
|
*/ |
774
|
|
|
public function addRecurrenceRule(RecurrenceRule $recurrenceRule) |
775
|
|
|
{ |
776
|
|
|
$this->recurrenceRules[] = $recurrenceRule; |
777
|
|
|
|
778
|
|
|
return $this; |
779
|
|
|
} |
780
|
|
|
|
781
|
|
|
/** |
782
|
|
|
* @return array |
783
|
|
|
*/ |
784
|
|
|
public function getRecurrenceRules() |
785
|
|
|
{ |
786
|
|
|
return $this->recurrenceRules; |
787
|
|
|
} |
788
|
|
|
|
789
|
|
|
/** |
790
|
|
|
* @param $dtStamp |
791
|
|
|
* |
792
|
|
|
* @return $this |
793
|
|
|
*/ |
794
|
|
|
public function setCreated($dtStamp) |
795
|
|
|
{ |
796
|
|
|
$this->created = $dtStamp; |
797
|
|
|
|
798
|
|
|
return $this; |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
/** |
802
|
|
|
* @param $dtStamp |
803
|
|
|
* |
804
|
|
|
* @return $this |
805
|
|
|
*/ |
806
|
|
|
public function setModified($dtStamp) |
807
|
|
|
{ |
808
|
|
|
$this->modified = $dtStamp; |
809
|
|
|
|
810
|
|
|
return $this; |
811
|
|
|
} |
812
|
|
|
|
813
|
|
|
/** |
814
|
|
|
* @param $categories |
815
|
|
|
* |
816
|
|
|
* @return $this |
817
|
|
|
*/ |
818
|
|
|
public function setCategories($categories) |
819
|
|
|
{ |
820
|
|
|
$this->categories = $categories; |
821
|
|
|
|
822
|
|
|
return $this; |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* Sets the event privacy. |
827
|
|
|
* |
828
|
|
|
* @param bool $flag |
829
|
|
|
* |
830
|
|
|
* @return $this |
831
|
|
|
*/ |
832
|
|
|
public function setIsPrivate($flag) |
833
|
|
|
{ |
834
|
|
|
$this->isPrivate = (bool) $flag; |
835
|
|
|
|
836
|
|
|
return $this; |
837
|
|
|
} |
838
|
|
|
|
839
|
|
|
/** |
840
|
|
|
* @param \DateTimeInterface $dateTime |
841
|
|
|
* |
842
|
|
|
* @return \Eluceo\iCal\Component\Event |
843
|
|
|
*/ |
844
|
|
|
public function addExDate(\DateTimeInterface $dateTime) |
845
|
|
|
{ |
846
|
|
|
$this->exDates[] = $dateTime; |
847
|
|
|
|
848
|
|
|
return $this; |
849
|
|
|
} |
850
|
|
|
|
851
|
|
|
/** |
852
|
|
|
* @return \DateTimeInterface[] |
853
|
|
|
*/ |
854
|
|
|
public function getExDates() |
855
|
|
|
{ |
856
|
|
|
return $this->exDates; |
857
|
|
|
} |
858
|
|
|
|
859
|
|
|
/** |
860
|
|
|
* @param \DateTimeInterface[] |
861
|
|
|
* |
862
|
|
|
* @return \Eluceo\iCal\Component\Event |
863
|
|
|
*/ |
864
|
|
|
public function setExDates(array $exDates) |
865
|
|
|
{ |
866
|
|
|
$this->exDates = $exDates; |
867
|
|
|
|
868
|
|
|
return $this; |
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
/** |
872
|
|
|
* @return \Eluceo\iCal\Property\Event\RecurrenceId |
873
|
|
|
*/ |
874
|
|
|
public function getRecurrenceId() |
875
|
|
|
{ |
876
|
|
|
return $this->recurrenceId; |
877
|
|
|
} |
878
|
|
|
|
879
|
|
|
/** |
880
|
|
|
* @param RecurrenceId $recurrenceId |
881
|
|
|
* |
882
|
|
|
* @return \Eluceo\iCal\Component\Event |
883
|
|
|
*/ |
884
|
|
|
public function setRecurrenceId(RecurrenceId $recurrenceId) |
885
|
|
|
{ |
886
|
|
|
$this->recurrenceId = $recurrenceId; |
887
|
|
|
|
888
|
|
|
return $this; |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
/** |
892
|
|
|
* @param array $attachment |
893
|
|
|
* |
894
|
|
|
* @return $this |
895
|
|
|
*/ |
896
|
1 |
|
public function addAttachment(Attachment $attachment) |
897
|
|
|
{ |
898
|
1 |
|
$this->attachments[] = $attachment; |
899
|
|
|
|
900
|
1 |
|
return $this; |
901
|
|
|
} |
902
|
|
|
|
903
|
|
|
/** |
904
|
|
|
* @return array |
905
|
|
|
*/ |
906
|
|
|
public function getAttachments() |
907
|
|
|
{ |
908
|
|
|
return $this->attachments; |
909
|
|
|
} |
910
|
|
|
|
911
|
|
|
/** |
912
|
|
|
* @param string $url |
913
|
|
|
*/ |
914
|
|
|
public function addUrlAttachment(string $url) |
915
|
|
|
{ |
916
|
|
|
$this->addAttachment(new Attachment($url)); |
917
|
|
|
} |
918
|
|
|
} |
919
|
|
|
|