summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-10-29 13:55:02 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-10-29 13:55:02 (GMT)
commitc1b4946e3e8270c5150bc5a7cc6be4f1b65e8619 (patch)
tree4789b41eabeeb05d9db22ac33bc3ccbe48f3c294
parent86c048e2d0057987ad66d11d43df0948dfdf1453 (diff)
downloadroundcubemail-plugins-kolab-roundcubemail-plugins-kolab-3.1.6.tar.gz
Fix VALARM parsing: ignore ACTION:NONE blocks; convert to ACTION:DISPLAY for the web client (#2415)roundcubemail-plugins-kolab-3.1.6
-rw-r--r--plugins/calendar/drivers/kolab/kolab_calendar.php4
-rw-r--r--plugins/libcalendaring/libvcalendar.php8
-rw-r--r--plugins/libcalendaring/tests/libvcalendar.php16
-rw-r--r--plugins/libcalendaring/tests/resources/apple-alarms.ics50
4 files changed, 75 insertions, 3 deletions
diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index d238e90..91c8d0c 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -579,6 +579,10 @@ class kolab_calendar
if (is_array($record['categories']))
$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
if (empty($record['recurrence']))
unset($record['recurrence']);
diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php
index c23d40b..5e12d50 100644
--- a/plugins/libcalendaring/libvcalendar.php
+++ b/plugins/libcalendaring/libvcalendar.php
@@ -426,15 +426,15 @@ class libvcalendar
}
// find alarms
- if ($valarms = $ve->select('VALARM')) {
+ foreach ($ve->select('VALARM') as $valarm) {
$action = 'DISPLAY';
$trigger = null;
- $valarm = reset($valarms);
foreach ($valarm->children as $prop) {
switch ($prop->name) {
case 'TRIGGER':
foreach ($prop->parameters as $param) {
+ console(strval($param->name), strval($param->value));
if ($param->name == 'VALUE' && $param->value == 'DATE-TIME') {
$trigger = '@' . $prop->getDateTime()->format('U');
}
@@ -450,8 +450,10 @@ class libvcalendar
}
}
- if ($trigger)
+ if ($trigger && strtoupper($action) != 'NONE') {
$event['alarms'] = $trigger . ':' . $action;
+ break;
+ }
}
// assign current timezone to event start/end
diff --git a/plugins/libcalendaring/tests/libvcalendar.php b/plugins/libcalendaring/tests/libvcalendar.php
index 3404473..92a22a3 100644
--- a/plugins/libcalendaring/tests/libvcalendar.php
+++ b/plugins/libcalendaring/tests/libvcalendar.php
@@ -153,6 +153,22 @@ class libvcalendar_test extends PHPUnit_Framework_TestCase
/**
* @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
+ */
function test_freebusy()
{
$ical = new libvcalendar();
diff --git a/plugins/libcalendaring/tests/resources/apple-alarms.ics b/plugins/libcalendaring/tests/resources/apple-alarms.ics
new file mode 100644
index 0000000..435d821
--- /dev/null
+++ b/plugins/libcalendaring/tests/resources/apple-alarms.ics
@@ -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 \ No newline at end of file