Always handle 'changed' properties of events as DateTime objects

This commit is contained in:
Thomas Bruederli 2013-07-18 14:06:45 +02:00
parent 2d831d8f8f
commit c2d97dfe36
4 changed files with 8 additions and 5 deletions

View file

@ -809,6 +809,8 @@ class calendar extends rcube_plugin
$action = 'import';
}
else if (in_array($status, array('ACCEPTED','TENTATIVE','DECLINED'))) {
if (is_numeric($event['changed']))
$event['changed'] = new DateTime('@'.$event['changed']);
$html = html::div('rsvp-status ' . strtolower($status), $this->gettext('youhave'.strtolower($status)));
if ($existing['sequence'] >= $event['sequence'] || (!$event['sequence'] && $existing['changed'] && $existing['changed'] >= $event['changed'])) {
$action = ''; // nothing to do here
@ -1199,6 +1201,7 @@ class calendar extends rcube_plugin
'_id' => $event['calendar'] . ':' . $event['id'], // unique identifier for fullcalendar
'start' => $this->lib->adjust_timezone($event['start'])->format('c'),
'end' => $this->lib->adjust_timezone($event['end'])->format('c'),
'changed' => $this->lib->adjust_timezone($event['changed'])->format('c'),
'title' => strval($event['title']),
'description' => strval($event['description']),
'location' => strval($event['location']),
@ -1854,7 +1857,7 @@ class calendar extends rcube_plugin
$buttons .= html::div(array('id' => 'import-'.$dom_id, 'style' => 'display:none'), $import_button);
$buttons_pre = html::div(array('id' => 'loading-'.$dom_id, 'class' => 'rsvp-status loading'), $this->gettext('loading'));
$this->rc->output->add_script('rcube_calendar.fetch_event_rsvp_status(' . json_serialize(array('uid' => $event['uid'], 'changed' => $event['changed'], 'sequence' => intval($event['sequence']), 'fallback' => $status)) . ')', 'docready');
$this->rc->output->add_script('rcube_calendar.fetch_event_rsvp_status(' . json_serialize(array('uid' => $event['uid'], 'changed' => $event['changed']->format('U'), 'sequence' => intval($event['sequence']), 'fallback' => $status)) . ')', 'docready');
}
else if ($this->ical->method == 'CANCEL') {
$title = $this->gettext('itipcancellation');
@ -1878,7 +1881,7 @@ class calendar extends rcube_plugin
$buttons .= html::div(array('id' => 'import-'.$dom_id, 'style' => 'display:none'), $button_import);
$buttons_pre = html::div(array('id' => 'loading-'.$dom_id, 'class' => 'rsvp-status loading'), $this->gettext('loading'));
$this->rc->output->add_script('rcube_calendar.fetch_event_rsvp_status(' . json_serialize(array('uid' => $event['uid'], 'changed' => $event['changed'], 'sequence' => intval($event['sequence']), 'fallback' => 'CANCELLED')) . ')', 'docready');
$this->rc->output->add_script('rcube_calendar.fetch_event_rsvp_status(' . json_serialize(array('uid' => $event['uid'], 'changed' => $event['changed']->format('U'), 'sequence' => intval($event['sequence']), 'fallback' => 'CANCELLED')) . ')', 'docready');
}
else {
$buttons = html::tag('input', array(

View file

@ -774,7 +774,7 @@ class database_driver extends calendar_driver
$event['start'] = new DateTime($event['start']);
$event['end'] = new DateTime($event['end']);
$event['allday'] = intval($event['all_day']);
$event['changed'] = strtotime($event['changed']);
$event['changed'] = new DateTime($event['changed']);
$event['free_busy'] = $free_busy_map[$event['free_busy']];
$event['calendar'] = $event['calendar_id'];
$event['recurrence_id'] = intval($event['recurrence_id']);

View file

@ -238,7 +238,7 @@ class calendar_itip
$this->sender = $attendee;
}
}
$invitation['event']['changed'] = time();
$invitation['event']['changed'] = new DateTime();
// send iTIP REPLY message to organizer
if ($organizer) {

View file

@ -141,7 +141,7 @@ class libvcalendar
{
$event = array(
'uid' => $ve->getAttributeDefault('UID'),
'changed' => $ve->getAttributeDefault('DTSTAMP', 0),
'changed' => $this->_date2time($ve->getAttributeDefault('DTSTAMP', 0)),
'title' => $ve->getAttributeDefault('SUMMARY'),
'start' => $this->_date2time($ve->getAttribute('DTSTART')),
'end' => $this->_date2time($ve->getAttribute('DTEND')),