]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix merging backend results
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 1 Nov 2016 11:15:14 +0000 (12:15 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Tue, 1 Nov 2016 11:16:05 +0000 (12:16 +0100)
* Merge share types correctly
* Filter share types
* Order share types

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/dav/lib/Connector/Sabre/SharesPlugin.php
apps/federatedfilesharing/lib/FederatedShareProvider.php
lib/private/Share20/DefaultShareProvider.php
lib/private/Share20/Manager.php

index ebb7fefff33ad3e1500958887d4da5a8ed361648..56d76e661846955d7a2cb71151edd2b564b9870f 100644 (file)
@@ -148,9 +148,12 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
                $values = array_map(function (\OCP\Files\Node $node) use ($shares) {
                        /** @var IShare[] $shares */
                        $shares = (isset($shares[$node->getId()])) ? $shares[$node->getId()] : [];
-                       return array_map(function(IShare $share) {
+                       $types = array_map(function(IShare $share) {
                                return $share->getShareType();
                        }, $shares);
+                       $types = array_unique($types);
+                       sort($types);
+                       return $types;
                }, $children);
 
                $keys = array_map(function (\OCP\Files\Node $node) {
index be155ac2daf5556c7a1e119f3906556f7c889588..270bf86daf7c9532e6d2bdae0b870b757bda0bda 100644 (file)
@@ -574,7 +574,7 @@ class FederatedShareProvider implements IShareProvider {
                                $qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
                        ))
                        ->andWhere(
-                               $qb->expr()->eq('shareType', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))
+                               $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))
                        );
 
                /**
index 60859c485c74b14a3c09cb0cf49783f012435735..bdb6ac466ecc6d90f140b0e0c2b2eca0038f1a4a 100644 (file)
@@ -466,7 +466,8 @@ class DefaultShareProvider implements IShareProvider {
 
                $qb->andWhere($qb->expr()->orX(
                        $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)),
-                       $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))
+                       $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)),
+                       $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))
                ));
 
                /**
index 9468a1de306af4a486f08b75df4b094bc52d9117..838650ada1534af3f5b52671ceb33f3bd3145104 100644 (file)
@@ -887,7 +887,15 @@ class Manager implements IManager {
                $providers = $this->factory->getAllProviders();
 
                return array_reduce($providers, function($shares, IShareProvider $provider) use ($userId, $node, $reshares) {
-                       return $shares + $provider->getSharesInFolder($userId, $node, $reshares);
+                       $newShares = $provider->getSharesInFolder($userId, $node, $reshares);
+                       foreach ($newShares as $fid => $data) {
+                               if (!isset($shares[$fid])) {
+                                       $shares[$fid] = [];
+                               }
+
+                               $shares[$fid] = array_merge($shares[$fid], $data);
+                       }
+                       return $shares;
                }, []);
        }