Fix merging backend results

* Merge share types correctly
* Filter share types
* Order share types

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2016-11-01 12:15:14 +01:00
parent ce7eb02685
commit fc4d0a86ef
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
4 changed files with 16 additions and 4 deletions

View 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) {

View 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))
);
/**

View 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))
));
/**

View 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;
}, []);
}