Fix VALARM parsing: ignore ACTION:NONE blocks; convert to ACTION:DISPLAY for the web client (#2415)
This commit is contained in:
parent
4cb0d62776
commit
310e25d0d1
4 changed files with 75 additions and 3 deletions
|
@ -579,6 +579,10 @@ class kolab_calendar
|
||||||
if (is_array($record['categories']))
|
if (is_array($record['categories']))
|
||||||
$record['categories'] = $record['categories'][0];
|
$record['categories'] = $record['categories'][0];
|
||||||
|
|
||||||
|
// The web client only supports DISPLAY type of alarms
|
||||||
|
if (!empty($record['alarms']))
|
||||||
|
$record['alarms'] = preg_replace('/:[A-Z]+$/', 'DISPLAY', $record['alarms']);
|
||||||
|
|
||||||
// remove empty recurrence array
|
// remove empty recurrence array
|
||||||
if (empty($record['recurrence']))
|
if (empty($record['recurrence']))
|
||||||
unset($record['recurrence']);
|
unset($record['recurrence']);
|
||||||
|
|
|
@ -549,15 +549,15 @@ class libvcalendar implements Iterator
|
||||||
}
|
}
|
||||||
|
|
||||||
// find alarms
|
// find alarms
|
||||||
if ($valarms = $ve->select('VALARM')) {
|
foreach ($ve->select('VALARM') as $valarm) {
|
||||||
$action = 'DISPLAY';
|
$action = 'DISPLAY';
|
||||||
$trigger = null;
|
$trigger = null;
|
||||||
|
|
||||||
$valarm = reset($valarms);
|
|
||||||
foreach ($valarm->children as $prop) {
|
foreach ($valarm->children as $prop) {
|
||||||
switch ($prop->name) {
|
switch ($prop->name) {
|
||||||
case 'TRIGGER':
|
case 'TRIGGER':
|
||||||
foreach ($prop->parameters as $param) {
|
foreach ($prop->parameters as $param) {
|
||||||
|
console(strval($param->name), strval($param->value));
|
||||||
if ($param->name == 'VALUE' && $param->value == 'DATE-TIME') {
|
if ($param->name == 'VALUE' && $param->value == 'DATE-TIME') {
|
||||||
$trigger = '@' . $prop->getDateTime()->format('U');
|
$trigger = '@' . $prop->getDateTime()->format('U');
|
||||||
}
|
}
|
||||||
|
@ -573,8 +573,10 @@ class libvcalendar implements Iterator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($trigger)
|
if ($trigger && strtoupper($action) != 'NONE') {
|
||||||
$event['alarms'] = $trigger . ':' . $action;
|
$event['alarms'] = $trigger . ':' . $action;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign current timezone to event start/end
|
// assign current timezone to event start/end
|
||||||
|
|
|
@ -186,6 +186,22 @@ class libvcalendar_test extends PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals('500px-Opensource.svg.png', $event['attachments'][0]['name']);
|
$this->assertEquals('500px-Opensource.svg.png', $event['attachments'][0]['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends test_import
|
||||||
|
*/
|
||||||
|
function test_apple_alarms()
|
||||||
|
{
|
||||||
|
$ical = new libvcalendar();
|
||||||
|
$events = $ical->import_from_file(__DIR__ . '/resources/apple-alarms.ics', 'UTF-8');
|
||||||
|
$event = $events[0];
|
||||||
|
|
||||||
|
// alarms
|
||||||
|
$this->assertEquals('-45M:AUDIO', $event['alarms'], "Relative alarm string");
|
||||||
|
$alarm = libcalendaring::parse_alaram_value($event['alarms']);
|
||||||
|
$this->assertEquals('45', $alarm[0], "Alarm value");
|
||||||
|
$this->assertEquals('-M', $alarm[1], "Alarm unit");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends test_import
|
* @depends test_import
|
||||||
*/
|
*/
|
||||||
|
|
50
plugins/libcalendaring/tests/resources/apple-alarms.ics
Normal file
50
plugins/libcalendaring/tests/resources/apple-alarms.ics
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Apple Inc.//Mac OS X 10.9//EN
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Zurich
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
||||||
|
DTSTART:19810329T020000
|
||||||
|
TZNAME:MESZ
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
||||||
|
DTSTART:19961027T030000
|
||||||
|
TZNAME:MEZ
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
BEGIN:VEVENT
|
||||||
|
TRANSP:OPAQUE
|
||||||
|
DTEND;TZID=Europe/Zurich:20131106T100000
|
||||||
|
UID:EF185A2A-55FA-4FF3-9B02-56B0914FC79A
|
||||||
|
DTSTAMP:20131029T123927Z
|
||||||
|
LOCATION:
|
||||||
|
DESCRIPTION:With alarm
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
SEQUENCE:4
|
||||||
|
X-APPLE-TRAVEL-DURATION:PT30M
|
||||||
|
SUMMARY:Testing Bug 2415
|
||||||
|
LAST-MODIFIED:20131029T123819Z
|
||||||
|
DTSTART;TZID=Europe/Zurich:20131106T090000
|
||||||
|
CREATED:20131029T123819Z
|
||||||
|
BEGIN:VALARM
|
||||||
|
X-WR-ALARMUID:C4A26F1A-A433-4102-82D5-A3347FC126D4
|
||||||
|
UID:C4A26F1A-A433-4102-82D5-A3347FC126D4
|
||||||
|
TRIGGER;VALUE=DATE-TIME:19760401T005545Z
|
||||||
|
ACTION:NONE
|
||||||
|
END:VALARM
|
||||||
|
BEGIN:VALARM
|
||||||
|
X-WR-ALARMUID:DEF5F23D-98FC-4510-BC99-F877CD9A9F8B
|
||||||
|
UID:DEF5F23D-98FC-4510-BC99-F877CD9A9F8B
|
||||||
|
TRIGGER;X-APPLE-RELATED-TRAVEL=-PT15M:-PT45M
|
||||||
|
ATTACH;VALUE=URI:Basso
|
||||||
|
ACTION:AUDIO
|
||||||
|
END:VALARM
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
Loading…
Add table
Reference in a new issue