diff options
-rw-r--r-- | apps/federatedfilesharing/lib/FederatedShareProvider.php | 2 | ||||
-rw-r--r-- | apps/federatedfilesharing/tests/FederatedShareProviderTest.php | 28 | ||||
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 22 | ||||
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 2 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 14 | ||||
-rw-r--r-- | tests/lib/Share20/DefaultShareProviderTest.php | 2 | ||||
-rw-r--r-- | tests/lib/Share20/ManagerTest.php | 2 |
7 files changed, 62 insertions, 10 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]; } } diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 93e8cfc9d77..b8f46a1f4d6 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -1138,6 +1138,6 @@ class DefaultShareProvider implements IShareProvider { return $count > 0; }); - return ['users' => array_keys($users), 'public' => $link, 'remote' => false]; + return ['users' => array_keys($users), 'public' => $link]; } } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 096d05fbec3..f1ce66f008c 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1236,9 +1236,17 @@ class Manager implements IManager { foreach ($providers as $provider) { $tmp = $provider->getAccessList($nodes, $currentAccess); - $al['users'] = array_merge($al['users'], $tmp['users']); - $al['public'] = $al['public'] || $tmp['public']; - $al['remote'] = $al['remote'] || $tmp['remote']; + foreach ($tmp as $k => $v) { + if (isset($al[$k])) { + if (is_array($al[$k])) { + $al[$k] = array_merge($al[$k], $v); + } else { + $al[$k] = $al[$k] || $v; + } + } else { + $al[$k] = $v; + } + } } $al['users'] = array_unique($al['users']); diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index ccc9f0f5112..a7f5555efaf 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -2508,7 +2508,6 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertContains('testShare4', $result['users']); $this->assertContains('testShare5', $result['users']); $this->assertTrue($result['public']); - $this->assertFalse($result['remote']); $provider->delete($share1); $provider->delete($share2); @@ -2595,7 +2594,6 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertContains('testShare3', $result['users']); $this->assertContains('testShare5', $result['users']); $this->assertTrue($result['public']); - $this->assertFalse($result['remote']); $provider->delete($share1); $provider->delete($share2); diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index ab42cb4813b..c1a0eaf5bb8 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -2804,7 +2804,6 @@ class ManagerTest extends \Test\TestCase { 'user2', 'user3', ], - 'remote' => false, 'public' => true, ]); @@ -2820,7 +2819,6 @@ class ManagerTest extends \Test\TestCase { 'user5', ], 'remote' => true, - 'public' => false, ]); $this->rootFolder->method('getUserFolder') |