From fc4d0a86efef1af4d7ea17547e259cfdd16e82b4 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 1 Nov 2016 12:15:14 +0100 Subject: [PATCH] Fix merging backend results * Merge share types correctly * Filter share types * Order share types Signed-off-by: Roeland Jago Douma --- apps/dav/lib/Connector/Sabre/SharesPlugin.php | 5 ++++- .../lib/FederatedShareProvider.php | 2 +- lib/private/Share20/DefaultShareProvider.php | 3 ++- lib/private/Share20/Manager.php | 10 +++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/SharesPlugin.php b/apps/dav/lib/Connector/Sabre/SharesPlugin.php index ebb7fefff33..56d76e66184 100644 --- a/apps/dav/lib/Connector/Sabre/SharesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/SharesPlugin.php @@ -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) { diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index be155ac2daf..270bf86daf7 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -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)) ); /** diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 60859c485c7..bdb6ac466ec 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -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)) )); /** diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 9468a1de306..838650ada15 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -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; }, []); } -- 2.39.5