Fix storing of (multiple) event alarms
This commit is contained in:
parent
b5d6faee6a
commit
291a6878cf
2 changed files with 21 additions and 7 deletions
|
@ -588,7 +588,13 @@ class libvcalendar implements Iterator
|
||||||
}
|
}
|
||||||
if (!$trigger && ($values = libcalendaring::parse_alaram_value($prop->value))) {
|
if (!$trigger && ($values = libcalendaring::parse_alaram_value($prop->value))) {
|
||||||
$trigger = $values[2];
|
$trigger = $values[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$alarm['trigger']) {
|
||||||
$alarm['trigger'] = rtrim(preg_replace('/([A-Z])0[WDHMS]/', '\\1', $prop->value), 'T');
|
$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;
|
break;
|
||||||
|
|
||||||
|
@ -612,10 +618,12 @@ class libvcalendar implements Iterator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($trigger && strtoupper($action) != 'NONE') {
|
if ($action != 'NONE') {
|
||||||
if (!$event['alarms']) // store first alarm in legacy property
|
if ($trigger && !$event['alarms']) // store first alarm in legacy property
|
||||||
$event['alarms'] = $trigger . ':' . $action;
|
$event['alarms'] = $trigger . ':' . $action;
|
||||||
$event['valarms'][] = $alarm;
|
|
||||||
|
if ($alarm['trigger'])
|
||||||
|
$event['valarms'][] = $alarm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,12 @@ abstract class kolab_format_xcal extends kolab_format
|
||||||
else if ($h = $offset->hours()) $time .= $h . 'H';
|
else if ($h = $offset->hours()) $time .= $h . 'H';
|
||||||
else if ($m = $offset->minutes()) $time .= $m . 'M';
|
else if ($m = $offset->minutes()) $time .= $m . 'M';
|
||||||
else if ($s = $offset->seconds()) $time .= $s . 'S';
|
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;
|
$object['alarms'] = $prefix . $value . $time;
|
||||||
$valarm['trigger'] = $prefix . 'P' . $value . ($time ? 'T' . $time : '');
|
$valarm['trigger'] = $prefix . 'P' . $value . ($time ? 'T' . $time : '');
|
||||||
|
@ -431,11 +436,11 @@ abstract class kolab_format_xcal extends kolab_format
|
||||||
$valarms = new vectoralarm;
|
$valarms = new vectoralarm;
|
||||||
if ($object['valarms']) {
|
if ($object['valarms']) {
|
||||||
foreach ($object['valarms'] as $valarm) {
|
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
|
continue; // skip unknown alarm types
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valarm['type'] == 'EMAIL') {
|
if ($valarm['action'] == 'EMAIL') {
|
||||||
$recipients = new vectorcontactref;
|
$recipients = new vectorcontactref;
|
||||||
foreach (($valarm['attendees'] ?: array($object['_owner'])) as $email) {
|
foreach (($valarm['attendees'] ?: array($object['_owner'])) as $email) {
|
||||||
$recipients->push(new ContactReference(ContactReference::EmailReference, $email));
|
$recipients->push(new ContactReference(ContactReference::EmailReference, $email));
|
||||||
|
@ -456,11 +461,12 @@ abstract class kolab_format_xcal extends kolab_format
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
$prefix = $valarm['trigger'][0];
|
$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 == '-');
|
$duration = new Duration($period->d, $period->h, $period->i, $period->s, $prefix == '-');
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
// skip alarm with invalid trigger values
|
// skip alarm with invalid trigger values
|
||||||
|
rcube::raise_error($e, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue