diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php index 2f01e524..138d2327 100644 --- a/plugins/libcalendaring/libvcalendar.php +++ b/plugins/libcalendaring/libvcalendar.php @@ -588,7 +588,13 @@ class libvcalendar implements Iterator } if (!$trigger && ($values = libcalendaring::parse_alaram_value($prop->value))) { $trigger = $values[2]; + } + + if (!$alarm['trigger']) { $alarm['trigger'] = rtrim(preg_replace('/([A-Z])0[WDHMS]/', '\\1', $prop->value), 'T'); + // if all 0-values have been stripped, assume 'at time' + if ($alarm['trigger'] == 'P') + $alarm['trigger'] = 'PT0S'; } break; @@ -612,10 +618,12 @@ class libvcalendar implements Iterator } } - if ($trigger && strtoupper($action) != 'NONE') { - if (!$event['alarms']) // store first alarm in legacy property + if ($action != 'NONE') { + if ($trigger && !$event['alarms']) // store first alarm in legacy property $event['alarms'] = $trigger . ':' . $action; - $event['valarms'][] = $alarm; + + if ($alarm['trigger']) + $event['valarms'][] = $alarm; } } diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php index b244450b..a14fa8a4 100644 --- a/plugins/libkolab/lib/kolab_format_xcal.php +++ b/plugins/libkolab/lib/kolab_format_xcal.php @@ -250,7 +250,12 @@ abstract class kolab_format_xcal extends kolab_format else if ($h = $offset->hours()) $time .= $h . 'H'; else if ($m = $offset->minutes()) $time .= $m . 'M'; else if ($s = $offset->seconds()) $time .= $s . 'S'; - else continue; + + // assume 'at event time' + if (empty($value) && empty($time)) { + $prefix = ''; + $time = '0S'; + } $object['alarms'] = $prefix . $value . $time; $valarm['trigger'] = $prefix . 'P' . $value . ($time ? 'T' . $time : ''); @@ -431,11 +436,11 @@ abstract class kolab_format_xcal extends kolab_format $valarms = new vectoralarm; if ($object['valarms']) { foreach ($object['valarms'] as $valarm) { - if (!array_key_exists($valarm['type'], $this->alarm_type_map)) { + if (!array_key_exists($valarm['action'], $this->alarm_type_map)) { continue; // skip unknown alarm types } - if ($valarm['type'] == 'EMAIL') { + if ($valarm['action'] == 'EMAIL') { $recipients = new vectorcontactref; foreach (($valarm['attendees'] ?: array($object['_owner'])) as $email) { $recipients->push(new ContactReference(ContactReference::EmailReference, $email)); @@ -456,11 +461,12 @@ abstract class kolab_format_xcal extends kolab_format else { try { $prefix = $valarm['trigger'][0]; - $period = new DateInterval(preg_replace('/[0-9PTWDHMS]/', '', $valarm['trigger'])); + $period = new DateInterval(preg_replace('/[^0-9PTWDHMS]/', '', $valarm['trigger'])); $duration = new Duration($period->d, $period->h, $period->i, $period->s, $prefix == '-'); } catch (Exception $e) { // skip alarm with invalid trigger values + rcube::raise_error($e, true); continue; }