forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iCalendar_components.php
694 lines (586 loc) · 26.4 KB
/
iCalendar_components.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
<?php
/**
* BENNU - PHP iCalendar library
* (c) 2005-2006 Ioannis Papaioannou ([email protected]). All rights reserved.
*
* Released under the LGPL.
*
* See http://bennu.sourceforge.net/ for more information and downloads.
*
* @author Ioannis Papaioannou
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/
class iCalendar_component {
var $name = NULL;
var $properties = NULL;
var $components = NULL;
var $valid_properties = NULL;
var $valid_components = NULL;
/**
* Added to hold errors from last run of unserialize
* @var $parser_errors array
*/
var $parser_errors = NULL;
function __construct() {
// Initialize the components array
if(empty($this->components)) {
$this->components = array();
foreach($this->valid_components as $name) {
$this->components[$name] = array();
}
}
}
function get_name() {
return $this->name;
}
function add_property($name, $value = NULL, $parameters = NULL) {
// Uppercase first of all
$name = strtoupper($name);
// Are we trying to add a valid property?
$xname = false;
if(!isset($this->valid_properties[$name])) {
// If not, is it an x-name as per RFC 2445?
if(!rfc2445_is_xname($name)) {
return false;
}
// Since this is an xname, all components are supposed to allow this property
$xname = true;
}
// Create a property object of the correct class
if($xname) {
$property = new iCalendar_property_x;
$property->set_name($name);
}
else {
$classname = 'iCalendar_property_'.strtolower(str_replace('-', '_', $name));
$property = new $classname;
}
// If $value is NULL, then this property must define a default value.
if($value === NULL) {
$value = $property->default_value();
if($value === NULL) {
return false;
}
}
// Set this property's parent component to ourselves, because some
// properties behave differently according to what component they apply to.
$property->set_parent_component($this->name);
// Set parameters before value; this helps with some properties which
// accept a VALUE parameter, and thus change their default value type.
// The parameters must be valid according to property specifications
if(!empty($parameters)) {
foreach($parameters as $paramname => $paramvalue) {
if(!$property->set_parameter($paramname, $paramvalue)) {
return false;
}
}
// Some parameters interact among themselves (e.g. ENCODING and VALUE)
// so make sure that after the dust settles, these invariants hold true
if(!$property->invariant_holds()) {
return false;
}
}
// $value MUST be valid according to the property data type
if(!$property->set_value($value)) {
return false;
}
// Check if the property already exists, and is limited to one occurrance,
// DON'T overwrite the value - this can be done explicity with set_value() instead.
if(!$xname && $this->valid_properties[$name] & RFC2445_ONCE && isset($this->properties[$name])) {
return false;
}
else {
// Otherwise add it to the instance array for this property
$this->properties[$name][] = $property;
}
// Finally: after all these, does the component invariant hold?
if(!$this->invariant_holds()) {
// If not, completely undo the property addition
array_pop($this->properties[$name]);
if(empty($this->properties[$name])) {
unset($this->properties[$name]);
}
return false;
}
return true;
}
function add_component($component) {
// With the detailed interface, you can add only components with this function
if(!is_object($component) || !is_subclass_of($component, 'iCalendar_component')) {
return false;
}
$name = $component->get_name();
// Only valid components as specified by this component are allowed
if(!in_array($name, $this->valid_components)) {
return false;
}
// Add it
$this->components[$name][] = $component;
return true;
}
function get_property_list($name) {
}
function invariant_holds() {
return true;
}
function is_valid() {
// If we have any child components, check that they are all valid
if(!empty($this->components)) {
foreach($this->components as $component => $instances) {
foreach($instances as $number => $instance) {
if(!$instance->is_valid()) {
return false;
}
}
}
}
// Finally, check the valid property list for any mandatory properties
// that have not been set and do not have a default value
foreach($this->valid_properties as $property => $propdata) {
if(($propdata & RFC2445_REQUIRED) && empty($this->properties[$property])) {
$classname = 'iCalendar_property_'.strtolower(str_replace('-', '_', $property));
$object = new $classname;
if($object->default_value() === NULL) {
return false;
}
unset($object);
}
}
return true;
}
function serialize() {
// Check for validity of the object
if(!$this->is_valid()) {
return false;
}
// Maybe the object is valid, but there are some required properties that
// have not been given explicit values. In that case, set them to defaults.
foreach($this->valid_properties as $property => $propdata) {
if(($propdata & RFC2445_REQUIRED) && empty($this->properties[$property])) {
$this->add_property($property);
}
}
// Start tag
$string = rfc2445_fold('BEGIN:'.$this->name) . RFC2445_CRLF;
// List of properties
if(!empty($this->properties)) {
foreach($this->properties as $name => $properties) {
foreach($properties as $property) {
$string .= $property->serialize();
}
}
}
// List of components
if(!empty($this->components)) {
foreach($this->components as $name => $components) {
foreach($components as $component) {
$string .= $component->serialize();
}
}
}
// End tag
$string .= rfc2445_fold('END:'.$this->name) . RFC2445_CRLF;
return $string;
}
/**
* unserialize()
*
* I needed a way to convert an iCalendar component back to a Bennu object so I could
* easily access and modify it after it had been stored; if this functionality is already
* present somewhere in the library, I apologize for adding it here unnecessarily; however,
* I couldn't find it so I added it myself.
* @param string $string the iCalendar object to load in to this iCalendar_component
* @return bool true if the file parsed with no errors. False if there were errors.
*/
function unserialize($string) {
$string = rfc2445_unfold($string); // Unfold any long lines
$lines = explode(RFC2445_CRLF, $string); // Create an array of lines
$components = array(); // Initialise a stack of components
$this->clear_errors();
foreach ($lines as $key => $line) {
// Divide the line up into label, parameters and data fields.
if (!preg_match('#^(?P<label>[-[:alnum:]]+)(?P<params>(?:;(?:(?:[-[:alnum:]]+)=(?:[^[:cntrl:]";:,]+|"[^[:cntrl:]"]+")))*):(?P<data>.*)$#', $line, $match)) {
$this->parser_error('Invalid line: '.$key.', ignoring');
continue;
}
// parse parameters
$params = array();
if (preg_match_all('#;(?P<param>[-[:alnum:]]+)=(?P<value>[^[:cntrl:]";:,]+|"[^[:cntrl:]"]+")#', $match['params'], $pmatch)) {
$params = array_combine($pmatch['param'], $pmatch['value']);
}
$label = $match['label'];
$data = $match['data'];
unset($match, $pmatch);
if ($label == 'BEGIN') {
// This is the start of a component.
$current_component = array_pop($components); // Get the current component off the stack so we can check its valid components
if ($current_component == null) { // If there's nothing on the stack
$current_component = $this; // use the iCalendar
}
if (in_array($data, $current_component->valid_components)) { // Check that the new component is a valid subcomponent of the current one
if($current_component != $this) {
array_push($components, $current_component); // We're done with the current component, put it back on the stack.
}
if(strpos($data, 'V') === 0) {
$data = substr($data, 1);
}
$cname = 'iCalendar_' . strtolower($data);
$new_component = new $cname;
array_push($components, $new_component); // Push a new component onto the stack
} else {
if($current_component != $this) {
array_push($components, $current_component);
$this->parser_error('Invalid component type on line '.$key);
}
}
unset($current_component, $new_component);
} else if ($label == 'END') {
// It's the END of a component.
$component = array_pop($components); // Pop the top component off the stack - we're now done with it
$parent_component = array_pop($components); // Pop the component's conatining component off the stack so we can add this component to it.
if($parent_component == null) {
$parent_component = $this; // If there's no components on the stack, use the iCalendar object
}
if ($parent_component->add_component($component) === false) {
$this->parser_error("Failed to add component on line $key");
}
if ($parent_component != $this) { // If we're not using the iCalendar
array_push($components, $parent_component); // Put the component back on the stack
}
unset($parent_component, $component);
} else {
$component = array_pop($components); // Get the component off the stack so we can add properties to it
if ($component == null) { // If there's nothing on the stack
$component = $this; // use the iCalendar
}
if ($component->add_property($label, $data, $params) === false) {
$this->parser_error("Failed to add property '$label' on line $key");
}
if($component != $this) { // If we're not using the iCalendar
array_push($components, $component); // Put the component back on the stack
}
unset($component);
}
}
}
function clear_errors() {
$this->parser_errors = array();
}
function parser_error($error) {
$this->parser_errors[] = $error;
}
}
class iCalendar extends iCalendar_component {
var $name = 'VCALENDAR';
function __construct() {
$this->valid_properties = array(
'CALSCALE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'METHOD' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PRODID' => RFC2445_REQUIRED | RFC2445_ONCE,
'VERSION' => RFC2445_REQUIRED | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
);
$this->valid_components = array(
'VEVENT', 'VTODO', 'VJOURNAL', 'VFREEBUSY', 'VTIMEZONE', 'VALARM'
);
parent::__construct();
}
}
class iCalendar_event extends iCalendar_component {
var $name = 'VEVENT';
var $properties;
function __construct() {
$this->valid_components = array('VALARM');
$this->valid_properties = array(
'CLASS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'CREATED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
// Standard ambiguous here: in 4.6.1 it says that DTSTAMP in optional,
// while in 4.8.7.2 it says it's REQUIRED. Go with REQUIRED.
'DTSTAMP' => RFC2445_REQUIRED | RFC2445_ONCE,
// Standard ambiguous here: in 4.6.1 it says that DTSTART in optional,
// while in 4.8.2.4 it says it's REQUIRED. Go with REQUIRED.
'DTSTART' => RFC2445_REQUIRED | RFC2445_ONCE,
'GEO' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LOCATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PRIORITY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SEQUENCE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'STATUS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TRANSP' => RFC2445_OPTIONAL | RFC2445_ONCE,
// Standard ambiguous here: in 4.6.1 it says that UID in optional,
// while in 4.8.4.7 it says it's REQUIRED. Go with REQUIRED.
'UID' => RFC2445_REQUIRED | RFC2445_ONCE,
'URL' => RFC2445_OPTIONAL | RFC2445_ONCE,
'RECURRENCE-ID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTEND' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ATTACH' => RFC2445_OPTIONAL,
'ATTENDEE' => RFC2445_OPTIONAL,
'CATEGORIES' => RFC2445_OPTIONAL,
'COMMENT' => RFC2445_OPTIONAL,
'CONTACT' => RFC2445_OPTIONAL,
'EXDATE' => RFC2445_OPTIONAL,
'EXRULE' => RFC2445_OPTIONAL,
'REQUEST-STATUS' => RFC2445_OPTIONAL,
'RELATED-TO' => RFC2445_OPTIONAL,
'RESOURCES' => RFC2445_OPTIONAL,
'RDATE' => RFC2445_OPTIONAL,
'RRULE' => RFC2445_OPTIONAL,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::__construct();
}
function invariant_holds() {
// DTEND and DURATION must not appear together
if(isset($this->properties['DTEND']) && isset($this->properties['DURATION'])) {
return false;
}
if(isset($this->properties['DTEND']) && isset($this->properties['DTSTART'])) {
// DTEND must be later than DTSTART
// The standard is not clear on how to hande different value types though
// TODO: handle this correctly even if the value types are different
if($this->properties['DTEND'][0]->value <= $this->properties['DTSTART'][0]->value) {
return false;
}
// DTEND and DTSTART must have the same value type
if($this->properties['DTEND'][0]->val_type != $this->properties['DTSTART'][0]->val_type) {
return false;
}
}
return true;
}
}
class iCalendar_todo extends iCalendar_component {
var $name = 'VTODO';
var $properties;
function __construct() {
$this->valid_components = array('VALARM');
$this->valid_properties = array(
'CLASS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'COMPLETED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'CREATED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTAMP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTAP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'GEO' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LOCATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PERCENT' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PRIORITY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'RECURID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SEQUENCE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'STATUS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'UID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'URL' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ATTACH' => RFC2445_OPTIONAL,
'ATTENDEE' => RFC2445_OPTIONAL,
'CATEGORIES' => RFC2445_OPTIONAL,
'COMMENT' => RFC2445_OPTIONAL,
'CONTACT' => RFC2445_OPTIONAL,
'EXDATE' => RFC2445_OPTIONAL,
'EXRULE' => RFC2445_OPTIONAL,
'RSTATUS' => RFC2445_OPTIONAL,
'RELATED' => RFC2445_OPTIONAL,
'RESOURCES' => RFC2445_OPTIONAL,
'RDATE' => RFC2445_OPTIONAL,
'RRULE' => RFC2445_OPTIONAL,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::__construct();
}
function invariant_holds() {
// DTEND and DURATION must not appear together
if(isset($this->properties['DTEND']) && isset($this->properties['DURATION'])) {
return false;
}
if(isset($this->properties['DTEND']) && isset($this->properties['DTSTART'])) {
// DTEND must be later than DTSTART
// The standard is not clear on how to hande different value types though
// TODO: handle this correctly even if the value types are different
if($this->properties['DTEND'][0]->value <= $this->properties['DTSTART'][0]->value) {
return false;
}
// DTEND and DTSTART must have the same value type
if($this->properties['DTEND'][0]->val_type != $this->properties['DTSTART'][0]->val_type) {
return false;
}
}
if(isset($this->properties['DUE']) && isset($this->properties['DTSTART'])) {
if($this->properties['DUE'][0]->value <= $this->properties['DTSTART'][0]->value) {
return false;
}
}
return true;
}
}
class iCalendar_journal extends iCalendar_component {
var $name = 'VJOURNAL';
var $properties;
function __construct() {
$this->valid_properties = array(
'CLASS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'CREATED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTART' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTAMP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'RECURRANCE-ID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SEQUENCE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'STATUS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'UID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'URL' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ATTACH' => RFC2445_OPTIONAL,
'ATTENDEE' => RFC2445_OPTIONAL,
'CATEGORIES' => RFC2445_OPTIONAL,
'COMMENT' => RFC2445_OPTIONAL,
'CONTACT' => RFC2445_OPTIONAL,
'EXDATE' => RFC2445_OPTIONAL,
'EXRULE' => RFC2445_OPTIONAL,
'RELATED-TO' => RFC2445_OPTIONAL,
'RDATE' => RFC2445_OPTIONAL,
'RRULE' => RFC2445_OPTIONAL,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::__construct();
}
}
class iCalendar_freebusy extends iCalendar_component {
var $name = 'VFREEBUSY';
var $properties;
function __construct() {
$this->valid_components = array();
$this->valid_properties = array(
'CONTACT' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTART' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTEND' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTAMP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'UID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'URL' => RFC2445_OPTIONAL | RFC2445_ONCE,
// TODO: the next two are components of their own!
'ATTENDEE' => RFC2445_OPTIONAL,
'COMMENT' => RFC2445_OPTIONAL,
'FREEBUSY' => RFC2445_OPTIONAL,
'RSTATUS' => RFC2445_OPTIONAL,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::__construct();
}
function invariant_holds() {
// DTEND and DURATION must not appear together
if(isset($this->properties['DTEND']) && isset($this->properties['DURATION'])) {
return false;
}
if(isset($this->properties['DTEND']) && isset($this->properties['DTSTART'])) {
// DTEND must be later than DTSTART
// The standard is not clear on how to hande different value types though
// TODO: handle this correctly even if the value types are different
if($this->properties['DTEND'][0]->value <= $this->properties['DTSTART'][0]->value) {
return false;
}
// DTEND and DTSTART must have the same value type
if($this->properties['DTEND'][0]->val_type != $this->properties['DTSTART'][0]->val_type) {
return false;
}
}
return true;
}
}
class iCalendar_alarm extends iCalendar_component {
var $name = 'VALARM';
var $properties;
function __construct() {
$this->valid_components = array();
$this->valid_properties = array(
'ACTION' => RFC2445_REQUIRED | RFC2445_ONCE,
'TRIGGER' => RFC2445_REQUIRED | RFC2445_ONCE,
// If one of these 2 occurs, so must the other.
'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'REPEAT' => RFC2445_OPTIONAL | RFC2445_ONCE,
// The following is required if action == "PROCEDURE" | "AUDIO"
'ATTACH' => RFC2445_OPTIONAL,
// The following is required if trigger == "EMAIL" | "DISPLAY"
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
// The following are required if action == "EMAIL"
'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ATTENDEE' => RFC2445_OPTIONAL,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::__construct();
}
function invariant_holds() {
// DTEND and DURATION must not appear together
if(isset($this->properties['ACTION'])) {
switch ($this->properties['ACTION'][0]->value) {
case 'AUDIO':
if (!isset($this->properties['ATTACH'])) {
return false;
}
break;
case 'DISPLAY':
if (!isset($this->properties['DESCRIPTION'])) {
return false;
}
break;
case 'EMAIL':
if (!isset($this->properties['DESCRIPTION']) || !isset($this->properties['SUMMARY']) || !isset($this->properties['ATTACH'])) {
return false;
}
break;
case 'PROCEDURE':
if (!isset($this->properties['ATTACH']) || count($this->properties['ATTACH']) > 1) {
return false;
}
break;
}
}
return true;
}
}
class iCalendar_timezone extends iCalendar_component {
var $name = 'VTIMEZONE';
var $properties;
function __construct() {
$this->valid_components = array('STANDARD', 'DAYLIGHT');
$this->valid_properties = array(
'TZID' => RFC2445_REQUIRED | RFC2445_ONCE,
'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TZURL' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::__construct();
}
}
class iCalendar_standard extends iCalendar_component {
var $name = 'STANDARD';
var $properties;
function __construct() {
$this->valid_components = array();
$this->valid_properties = array(
'DTSTART' => RFC2445_REQUIRED | RFC2445_ONCE,
'TZOFFSETTO' => RFC2445_REQUIRED | RFC2445_ONCE,
'TZOFFSETFROM' => RFC2445_REQUIRED | RFC2445_ONCE,
'COMMENT' => RFC2445_OPTIONAL,
'RDATE' => RFC2445_OPTIONAL,
'RRULE' => RFC2445_OPTIONAL,
'TZNAME' => RFC2445_OPTIONAL,
RFC2445_XNAME => RFC2445_OPTIONAL,
);
parent::__construct();
}
}
class iCalendar_daylight extends iCalendar_standard {
var $name = 'DAYLIGHT';
}
// REMINDER: DTEND must be later than DTSTART for all components which support both
// REMINDER: DUE must be later than DTSTART for all components which support both