From 2cbac3357ba445a3a4cd073e119efb871ea0f719 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 22 Dec 2016 21:44:21 +0100 Subject: Offload acceslist creation to providers * This allows for effective queries. * Introduce currentAccess parameter to speciy if the users needs to have currently acces (deleted incomming group share). (For notifications) Signed-off-by: Roeland Jago Douma --- .../lib/FederatedShareProvider.php | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'apps/federatedfilesharing/lib') diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 120365263a9..b54f8a69fd1 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -28,6 +28,7 @@ namespace OCA\FederatedFileSharing; use OC\Share20\Share; use OCP\Federation\ICloudIdManager; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\IConfig; @@ -974,4 +975,28 @@ class FederatedShareProvider implements IShareProvider { $result = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); return ($result === 'yes'); } + + public function getAccessList($nodes, $currentAccess) { + $ids = []; + foreach ($nodes as $node) { + $ids[] = $node->getId(); + } + + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('share_with') + ->from('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))) + ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) + ->setMaxResults(1); + $cursor = $qb->execute(); + + $remote = $cursor->fetch() !== false; + $cursor->closeCursor(); + + return ['users' => [], 'remote' => $remote, 'public' => false]; + } } -- cgit v1.2.3