diff options
author | Joas Schilling <coding@schilljs.com> | 2017-03-02 11:34:27 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-03-02 12:28:57 +0100 |
commit | 2eb27c636d7fc73e9d25f8531b49f96908506a19 (patch) | |
tree | bfb750dcff89447e5afa41267e51d2a2010c1b0a /apps/dav/lib/CardDAV | |
parent | 6dbdca0721902cf9224f8ec42ff5170810afd388 (diff) | |
download | nextcloud-server-2eb27c636d7fc73e9d25f8531b49f96908506a19.tar.gz nextcloud-server-2eb27c636d7fc73e9d25f8531b49f96908506a19.zip |
Make sure shares use read-write when available
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav/lib/CardDAV')
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index ac4b58f5385..6f9a73298ef 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -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(); |