diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php index 1884bbab..38441e00 100644 --- a/plugins/libcalendaring/libvcalendar.php +++ b/plugins/libcalendaring/libvcalendar.php @@ -440,6 +440,13 @@ class libvcalendar implements Iterator $event['status'] = $value; break; + case 'COMPLETED': + if (self::convert_datetime($prop)) { + $event['status'] = 'COMPLETED'; + $event['complete'] = 100; + } + break; + case 'PRIORITY': if (is_numeric($value)) $event['priority'] = $value; @@ -1089,9 +1096,11 @@ class libvcalendar implements Iterator if (!empty($event['complete'])) { $ve->add('PERCENT-COMPLETE', intval($event['complete'])); - // Apple iCal required the COMPLETED date to be set in order to consider a task complete - if ($event['complete'] == 100) - $ve->add($this->datetime_prop($cal, 'COMPLETED', $event['changed'] ?: new DateTime('now - 1 hour'), true)); + } + + // Apple iCal and BusyCal required the COMPLETED date to be set in order to consider a task complete + if ($event['status'] == 'COMPLETED' || $event['complete'] == 100) { + $ve->add($this->datetime_prop($cal, 'COMPLETED', $event['changed'] ?: new DateTime('now - 1 hour'), true)); } if ($event['valarms']) { diff --git a/plugins/libcalendaring/tests/libvcalendar.php b/plugins/libcalendaring/tests/libvcalendar.php index d401a960..24a646f0 100644 --- a/plugins/libcalendaring/tests/libvcalendar.php +++ b/plugins/libcalendaring/tests/libvcalendar.php @@ -348,6 +348,13 @@ class libvcalendar_test extends PHPUnit_Framework_TestCase $this->assertEquals(1, count($task['x-custom']), "Custom properties"); $this->assertEquals(4, count($task['categories'])); $this->assertEquals('1234567890-12345678-PARENT', $task['parent_id'], "Parent Relation"); + + $completed = $tasks[1]; + $this->assertEquals('COMPLETED', $completed['status'], "Task status=completed when COMPLETED property is present"); + $this->assertEquals(100, $completed['complete'], "Task percent complete value"); + + $ics = $ical->export(array($completed)); + $this->assertRegExp('/COMPLETED:[0-9TZ]+/', $ics, "Export COMPLETED property"); } /** diff --git a/plugins/libcalendaring/tests/resources/vtodo.ics b/plugins/libcalendaring/tests/resources/vtodo.ics index 746787da..8d3d8a62 100644 --- a/plugins/libcalendaring/tests/resources/vtodo.ics +++ b/plugins/libcalendaring/tests/resources/vtodo.ics @@ -40,4 +40,16 @@ TRIGGER;VALUE=DURATION:-P1D DESCRIPTION:Default Mozilla Description END:VALARM END:VTODO + +BEGIN:VTODO +SUMMARY:Send and receive iTip messages with task assignments +UID:7ADB358AD071AA00306962BF329EF317-FCBB6C4091F28CA0 +SEQUENCE:0 +DTSTAMP:20150527T101614Z +CREATED:20140801T091954Z +LAST-MODIFIED:20150527T101611Z +COMPLETED:20150527T101611Z +X-BUSYMAC-LASTMODBY:Thomas BrĂ¼derli +END:VTODO + END:VCALENDAR