parent
2d2d2267f7
commit
7d95cde37d
2 changed files with 22 additions and 11 deletions
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue