]> source.dussan.org Git - nextcloud-server.git/commitdiff
Reassemble behavior on shared address books with respect to uri and displayname
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 21 Jan 2016 15:20:52 +0000 (16:20 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 26 Jan 2016 14:07:50 +0000 (15:07 +0100)
apps/dav/appinfo/database.xml
apps/dav/appinfo/info.xml
apps/dav/lib/carddav/carddavbackend.php
apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml

index 50c8aa7d8ca547b4232f476e795fbe885d25bd83..4221e590fa58b735816227cc49fd644820278d60 100644 (file)
@@ -655,10 +655,6 @@ CREATE TABLE calendarobjects (
                                <unsigned>true</unsigned>
                                <length>11</length>
                        </field>
-                       <field>
-                               <name>uri</name>
-                               <type>text</type>
-                       </field>
                        <field>
                                <name>principaluri</name>
                                <type>text</type>
@@ -685,7 +681,7 @@ CREATE TABLE calendarobjects (
                                        <name>principaluri</name>
                                </field>
                                <field>
-                                       <name>uri</name>
+                                       <name>resourceid</name>
                                </field>
                                <field>
                                        <name>type</name>
index d9eefaefcf1a037f115e2f82d3038dcd25f7667a..3a38feab59e5a6963001ea67526e35aff77b7f6b 100644 (file)
@@ -5,7 +5,7 @@
        <description>ownCloud WebDAV endpoint</description>
        <licence>AGPL</licence>
        <author>owncloud.org</author>
-       <version>0.1.3</version>
+       <version>0.1.4</version>
        <standalone/>
        <default_enable/>
        <types>
index 44164e6125971f1012b24561f761e1d926bc8800..28f6099b6392228597cbd34013e106f9ee82ae06 100644 (file)
@@ -24,6 +24,7 @@
 
 namespace OCA\DAV\CardDAV;
 
+use Doctrine\DBAL\Connection;
 use OCA\DAV\Connector\Sabre\Principal;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
@@ -31,6 +32,7 @@ use Sabre\CardDAV\Backend\BackendInterface;
 use Sabre\CardDAV\Backend\SyncSupport;
 use Sabre\CardDAV\Plugin;
 use Sabre\DAV\Exception\BadRequest;
+use Sabre\HTTP\URLUtil;
 use Sabre\VObject\Component\VCard;
 use Sabre\VObject\Reader;
 
@@ -113,7 +115,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                $principals[]= $principalUri;
 
                $query = $this->db->getQueryBuilder();
-               $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.uri', 's.access'])
+               $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access'])
                        ->from('dav_shares', 's')
                        ->join('s', 'addressbooks', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
                        ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
@@ -123,11 +125,14 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        ->execute();
 
                while($row = $result->fetch()) {
+                       list(, $name) = URLUtil::splitPath($row['principaluri']);
+                       $uri = $row['uri'] . '_shared_by_' . $name;
+                       $displayName = $row['displayname'] . "($name)";
                        $addressBooks[] = [
                                'id'  => $row['id'],
-                               'uri' => $row['uri'],
+                               'uri' => $uri,
                                'principaluri' => $principalUri,
-                               '{DAV:}displayname' => $row['displayname'],
+                               '{DAV:}displayname' => $displayName,
                                '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
                                '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
                                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
@@ -826,12 +831,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        $access = $element['readOnly'] ? self::ACCESS_READ : self::ACCESS_READ_WRITE;
                }
 
-               $newUri = sha1($addressBook->getName() . $addressBook->getOwner());
                $query = $this->db->getQueryBuilder();
                $query->insert('dav_shares')
                        ->values([
                                'principaluri' => $query->createNamedParameter($parts[1]),
-                               'uri' => $query->createNamedParameter($newUri),
                                'type' => $query->createNamedParameter('addressbook'),
                                'access' => $query->createNamedParameter($access),
                                'resourceid' => $query->createNamedParameter($addressBook->getBookId())
index 046c3d59dbd674f27ae6acabcaeeaeb5dc30fd51..37b4941b9f1b787cee66971565a8129ced7c6c0d 100644 (file)
@@ -78,7 +78,7 @@
                                        <callback>xmlElementMatch</callback>
                                        <arg>
                                                <name>parent</name>
-                                               <value>$multistatus-response-prefix:[^{DAV:}href=$addressbookhome2:/ade1a55d408167e8ff77611c0eebe8f80579b549/]</value>
+                                               <value>$multistatus-response-prefix:[^{DAV:}href=$addressbookhome2:/addressbook_shared_by_user01/]</value>
                                        </arg>
                                        <arg>
                                                <name>exists</name>