Validate/fix dates only for event objects; don't export default values
This commit is contained in:
parent
2654abfcaf
commit
17dbcd9c9f
1 changed files with 21 additions and 18 deletions
|
@ -191,7 +191,6 @@ class libvcalendar
|
|||
'changed' => null,
|
||||
'_type' => $ve->name == 'VTODO' ? 'task' : 'event',
|
||||
// set defaults
|
||||
'free_busy' => 'busy',
|
||||
'priority' => 0,
|
||||
'attendees' => array(),
|
||||
);
|
||||
|
@ -350,22 +349,25 @@ class libvcalendar
|
|||
}
|
||||
}
|
||||
|
||||
// check for all-day dates
|
||||
if ($event['start']->_dateonly) {
|
||||
$event['allday'] = true;
|
||||
}
|
||||
// validate event dates
|
||||
if ($event['_type'] == 'event') {
|
||||
// check for all-day dates
|
||||
if ($event['start']->_dateonly) {
|
||||
$event['allday'] = true;
|
||||
}
|
||||
|
||||
// shift end-date by one day (except Thunderbird)
|
||||
if ($event['allday'] && is_object($event['end'])) {
|
||||
$event['end']->sub(new \DateInterval('PT23H'));
|
||||
}
|
||||
// shift end-date by one day (except Thunderbird)
|
||||
if ($event['allday'] && is_object($event['end'])) {
|
||||
$event['end']->sub(new \DateInterval('PT23H'));
|
||||
}
|
||||
|
||||
// sanity-check and fix end date
|
||||
if (empty($event['end'])) {
|
||||
$event['end'] = clone $event['start'];
|
||||
}
|
||||
else if ($event['end'] < $event['start']) {
|
||||
$event['end'] = clone $event['start'];
|
||||
// sanity-check and fix end date
|
||||
if (empty($event['end'])) {
|
||||
$event['end'] = clone $event['start'];
|
||||
}
|
||||
else if ($event['end'] < $event['start']) {
|
||||
$event['end'] = clone $event['start'];
|
||||
}
|
||||
}
|
||||
|
||||
// make organizer part of the attendees list for compatibility reasons
|
||||
|
@ -610,7 +612,8 @@ class libvcalendar
|
|||
$ve->add($cat);
|
||||
}
|
||||
|
||||
$ve->add('TRANSP', $event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE');
|
||||
if (!empty($event['free_busy']))
|
||||
$ve->add('TRANSP', $event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE');
|
||||
|
||||
if ($event['priority'])
|
||||
$ve->add('PRIORITY', $event['priority']);
|
||||
|
@ -625,7 +628,7 @@ class libvcalendar
|
|||
if (!empty($event['sensitivity']))
|
||||
$ve->add('CLASS', strtoupper($event['sensitivity']));
|
||||
|
||||
if (isset($event['complete'])) {
|
||||
if (!empty($event['complete'])) {
|
||||
$ve->add('PERCENT-COMPLETE', intval($event['complete']));
|
||||
// Apple iCal required the COMPLETED date to be set in order to consider a task complete
|
||||
if ($event['complete'] == 100)
|
||||
|
|
Loading…
Add table
Reference in a new issue