mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Fix CalDAV subscriptions calendarorder column/prop type
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
12db5e1a67
commit
337a3238bd
1 changed files with 33 additions and 25 deletions
|
|
@ -96,6 +96,7 @@ use Sabre\VObject\Reader;
|
|||
use Sabre\VObject\Recur\EventIterator;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
use function array_column;
|
||||
use function array_merge;
|
||||
use function array_values;
|
||||
use function explode;
|
||||
|
|
@ -163,13 +164,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* @var array
|
||||
*/
|
||||
public $subscriptionPropertyMap = [
|
||||
'{DAV:}displayname' => 'displayname',
|
||||
'{http://apple.com/ns/ical/}refreshrate' => 'refreshrate',
|
||||
'{http://apple.com/ns/ical/}calendar-order' => 'calendarorder',
|
||||
'{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor',
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos',
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms',
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments',
|
||||
'{DAV:}displayname' => ['displayname', 'string'],
|
||||
'{http://apple.com/ns/ical/}refreshrate' => ['refreshrate', 'string'],
|
||||
'{http://apple.com/ns/ical/}calendar-order' => ['calendarorder', 'int'],
|
||||
'{http://apple.com/ns/ical/}calendar-color' => ['calendarcolor', 'string'],
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-todos' => ['striptodos', 'bool'],
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-alarms' => ['stripalarms', 'string'],
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-attachments' => ['stripattachments', 'string'],
|
||||
];
|
||||
|
||||
/** @var array properties to index */
|
||||
|
|
@ -747,7 +748,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* @param $subscriptionId
|
||||
*/
|
||||
public function getSubscriptionById($subscriptionId) {
|
||||
$fields = array_values($this->subscriptionPropertyMap);
|
||||
$fields = array_column($this->subscriptionPropertyMap, 0);
|
||||
$fields[] = 'id';
|
||||
$fields[] = 'uri';
|
||||
$fields[] = 'source';
|
||||
|
|
@ -779,13 +780,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
];
|
||||
|
||||
foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) {
|
||||
if (!is_null($row[$dbName])) {
|
||||
$subscription[$xmlName] = $row[$dbName];
|
||||
}
|
||||
}
|
||||
|
||||
return $subscription;
|
||||
return $this->rowToSubscription($row, $subscription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2366,7 +2361,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* @return array
|
||||
*/
|
||||
public function getSubscriptionsForUser($principalUri) {
|
||||
$fields = array_values($this->subscriptionPropertyMap);
|
||||
$fields = array_column($this->subscriptionPropertyMap, 0);
|
||||
$fields[] = 'id';
|
||||
$fields[] = 'uri';
|
||||
$fields[] = 'source';
|
||||
|
|
@ -2394,13 +2389,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
];
|
||||
|
||||
foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) {
|
||||
if (!is_null($row[$dbName])) {
|
||||
$subscription[$xmlName] = $row[$dbName];
|
||||
}
|
||||
}
|
||||
|
||||
$subscriptions[] = $subscription;
|
||||
$subscriptions[] = $this->rowToSubscription($row, $subscription);
|
||||
}
|
||||
|
||||
return $subscriptions;
|
||||
|
|
@ -2431,7 +2420,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
|
||||
$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
|
||||
|
||||
foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) {
|
||||
foreach ($this->subscriptionPropertyMap as $xmlName => [$dbName, $type]) {
|
||||
if (array_key_exists($xmlName, $properties)) {
|
||||
$values[$dbName] = $properties[$xmlName];
|
||||
if (in_array($dbName, $propertiesBoolean)) {
|
||||
|
|
@ -2493,7 +2482,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
if ($propertyName === '{http://calendarserver.org/ns/}source') {
|
||||
$newValues['source'] = $propertyValue->getHref();
|
||||
} else {
|
||||
$fieldName = $this->subscriptionPropertyMap[$propertyName];
|
||||
$fieldName = $this->subscriptionPropertyMap[$propertyName][0];
|
||||
$newValues[$fieldName] = $propertyValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -3196,4 +3185,23 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
}
|
||||
return $calendar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Amend the subscription info with database row data
|
||||
*
|
||||
* @param array $row
|
||||
* @param array $subscription
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function rowToSubscription($row, array $subscription): array {
|
||||
foreach ($this->subscriptionPropertyMap as $xmlName => [$dbName, $type]) {
|
||||
$value = $row[$dbName];
|
||||
if ($value !== null) {
|
||||
settype($value, $type);
|
||||
}
|
||||
$subscription[$xmlName] = $value;
|
||||
}
|
||||
return $subscription;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue