]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make sure shares use read-write when available 3678/head
authorJoas Schilling <coding@schilljs.com>
Thu, 2 Mar 2017 10:34:27 +0000 (11:34 +0100)
committerJoas Schilling <coding@schilljs.com>
Thu, 2 Mar 2017 11:28:57 +0000 (12:28 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/dav/lib/CalDAV/CalDavBackend.php
apps/dav/lib/CardDAV/CardDavBackend.php

index e8f1cf979a5bfa53164b8de231d6e99beb1382b7..dbe86438238598a0a7fa13fc455f1b7ca41b218f 100644 (file)
@@ -277,9 +277,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
                        ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
                        ->execute();
 
+               $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
                while($row = $result->fetch()) {
+                       $readOnly = (int) $row['access'] === Backend::ACCESS_READ;
                        if (isset($calendars[$row['id']])) {
-                               continue;
+                               if ($readOnly) {
+                                       // New share can not have more permissions then the old one.
+                                       continue;
+                               }
+                               if (isset($calendars[$row['id']][$readOnlyPropertyName]) &&
+                                       $calendars[$row['id']][$readOnlyPropertyName] === 0) {
+                                       // Old share is already read-write, no more permissions can be gained
+                                       continue;
+                               }
                        }
 
                        list(, $name) = URLUtil::splitPath($row['principaluri']);
@@ -298,7 +308,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
                                '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
                                '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
                                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
-                               '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
+                               $readOnlyPropertyName => $readOnly,
                        ];
 
                        foreach($this->propertyMap as $xmlName=>$dbName) {
index ac4b58f53854c47a53d73d95aba8bf92021a27da..6f9a73298ef3ba483712d3a9abbe1b2d860579bd 100644 (file)
@@ -172,9 +172,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        ->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)
                        ->execute();
 
+               $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
                while($row = $result->fetch()) {
+                       $readOnly = (int) $row['access'] === Backend::ACCESS_READ;
                        if (isset($addressBooks[$row['id']])) {
-                               continue;
+                               if ($readOnly) {
+                                       // New share can not have more permissions then the old one.
+                                       continue;
+                               }
+                               if (isset($addressBooks[$row['id']][$readOnlyPropertyName]) &&
+                                       $addressBooks[$row['id']][$readOnlyPropertyName] === 0) {
+                                       // Old share is already read-write, no more permissions can be gained
+                                       continue;
+                               }
                        }
 
                        list(, $name) = URLUtil::splitPath($row['principaluri']);
@@ -190,7 +200,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                                '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
                                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
                                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
-                               '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
+                               $readOnlyPropertyName => $readOnly,
                        ];
                }
                $result->closeCursor();