From 12afd7d1d5bc2a85d04815964bf7fb37e77466d6 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 4 Jan 2017 08:59:43 +0100 Subject: Add mail element to access list * Each provider just returns what they have so adding an element won't require changing everything * Added tests Signed-off-by: Roeland Jago Douma --- apps/sharebymail/lib/ShareByMailProvider.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'apps/sharebymail') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index c367130487d..14ed12749b7 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -835,7 +835,27 @@ class ShareByMailProvider implements IShareProvider { } public function getAccessList($nodes, $currentAccess) { - return ['users' => [], 'remote' => false, 'public' => false]; + $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_EMAIL))) + ->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(); + + $mail = $cursor->fetch() !== false; + $cursor->closeCursor(); + + return ['mail' => $mail]; } } -- cgit v1.2.3