summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-01-04 08:59:43 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2017-04-13 12:58:50 +0200
commit12afd7d1d5bc2a85d04815964bf7fb37e77466d6 (patch)
tree11cd311669ab0b2895e3d471bcf974e3f287e31d /apps
parent2cbac3357ba445a3a4cd073e119efb871ea0f719 (diff)
downloadnextcloud-server-12afd7d1d5bc2a85d04815964bf7fb37e77466d6.tar.gz
nextcloud-server-12afd7d1d5bc2a85d04815964bf7fb37e77466d6.zip
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 <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php2
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php28
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php22
3 files changed, 50 insertions, 2 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index b54f8a69fd1..29aa594df54 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -997,6 +997,6 @@ class FederatedShareProvider implements IShareProvider {
$remote = $cursor->fetch() !== false;
$cursor->closeCursor();
- return ['users' => [], 'remote' => $remote, 'public' => false];
+ return ['remote' => $remote];
}
}
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index d9bc9a7e2ad..7d571b2082c 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -788,4 +788,32 @@ class FederatedShareProviderTest extends \Test\TestCase {
$u1->delete();
$u2->delete();
}
+
+ public function testGetAccessList() {
+ $userManager = \OC::$server->getUserManager();
+ $rootFolder = \OC::$server->getRootFolder();
+
+ $u1 = $userManager->createUser('testFed', md5(time()));
+
+ $folder1 = $rootFolder->getUserFolder($u1->getUID())->newFolder('foo');
+ $file1 = $folder1->newFile('bar1');
+
+ $this->tokenHandler->method('generateToken')->willReturn('token');
+ $this->notifications
+ ->method('sendRemoteShare')
+ ->willReturn(true);
+
+ $share1 = $this->shareManager->newShare();
+ $share1->setSharedWith('user@server.com')
+ ->setSharedBy($u1->getUID())
+ ->setShareOwner($u1->getUID())
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setNode($file1);
+ $this->provider->create($share1);
+
+ $result = $this->provider->getAccessList([$file1], true);
+
+ $this->assertSame(['remote' => true], $result);
+ $u1->delete();
+ }
}
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];
}
}