summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php25
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php8
2 files changed, 22 insertions, 11 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index ce494082976..565ad0ec663 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -1079,22 +1079,27 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'lastmodified' => time(),
];
- foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
- if (isset($properties[$xmlName])) {
+ $propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
- $values[$dbName] = $properties[$xmlName];
- $fieldNames[] = $dbName;
+ foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
+ if (array_key_exists($xmlName, $properties)) {
+ $values[$dbName] = $properties[$xmlName];
+ if (in_array($dbName, $propertiesBoolean)) {
+ $values[$dbName] = true;
+ }
}
}
+ $valuesToInsert = array();
+
$query = $this->db->getQueryBuilder();
+
+ foreach (array_keys($values) as $name) {
+ $valuesToInsert[$name] = $query->createNamedParameter($values[$name]);
+ }
+
$query->insert('calendarsubscriptions')
- ->values([
- 'principaluri' => $query->createNamedParameter($values['principaluri']),
- 'uri' => $query->createNamedParameter($values['uri']),
- 'source' => $query->createNamedParameter($values['source']),
- 'lastmodified' => $query->createNamedParameter($values['lastmodified']),
- ])
+ ->values($valuesToInsert)
->execute();
return $this->db->lastInsertId('*PREFIX*calendarsubscriptions');
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
index 977bdf15c8e..baa8540c43c 100644
--- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
@@ -333,15 +333,20 @@ EOD;
public function testSubscriptions() {
$id = $this->backend->createSubscription(self::UNIT_TEST_USER, 'Subscription', [
- '{http://calendarserver.org/ns/}source' => new Href('test-source')
+ '{http://calendarserver.org/ns/}source' => new Href('test-source'),
+ '{http://apple.com/ns/ical/}calendar-color' => '#1C4587',
+ '{http://calendarserver.org/ns/}subscribed-strip-todos' => ''
]);
$subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER);
$this->assertEquals(1, count($subscriptions));
+ $this->assertEquals('#1C4587', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']);
+ $this->assertEquals(true, $subscriptions[0]['{http://calendarserver.org/ns/}subscribed-strip-todos']);
$this->assertEquals($id, $subscriptions[0]['id']);
$patch = new PropPatch([
'{DAV:}displayname' => 'Unit test',
+ '{http://apple.com/ns/ical/}calendar-color' => '#ac0606',
]);
$this->backend->updateSubscription($id, $patch);
$patch->commit();
@@ -350,6 +355,7 @@ EOD;
$this->assertEquals(1, count($subscriptions));
$this->assertEquals($id, $subscriptions[0]['id']);
$this->assertEquals('Unit test', $subscriptions[0]['{DAV:}displayname']);
+ $this->assertEquals('#ac0606', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']);
$this->backend->deleteSubscription($id);
$subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER);