diff options
author | Joas Schilling <coding@schilljs.com> | 2017-04-11 12:40:36 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-13 12:58:52 +0200 |
commit | 629b7c0fc38d9a2c33805bfcf4359e263e4ae68f (patch) | |
tree | 915d48dcfbc021fad3cbff2a5c53e7de006e630e /apps | |
parent | 6c23a5fa3511e5212c83e8407fa18b12ec975f97 (diff) | |
download | nextcloud-server-629b7c0fc38d9a2c33805bfcf4359e263e4ae68f.tar.gz nextcloud-server-629b7c0fc38d9a2c33805bfcf4359e263e4ae68f.zip |
Adjust docs and make !$currentAccess simpler
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
4 files changed, 30 insertions, 1 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 617db4a45ac..34e02391e05 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -976,6 +976,9 @@ class FederatedShareProvider implements IShareProvider { return ($result === 'yes'); } + /** + * @inheritdoc + */ public function getAccessList($nodes, $currentAccess) { $ids = []; foreach ($nodes as $node) { @@ -993,6 +996,13 @@ class FederatedShareProvider implements IShareProvider { )); $cursor = $qb->execute(); + if ($currentAccess === false) { + $remote = $cursor->fetch() !== false; + $cursor->closeCursor(); + + return ['remote' => $remote]; + } + $remote = []; while ($row = $cursor->fetch()) { $remote[$row['share_with']] = [ diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 788ae47fded..e01e02c83ba 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -805,6 +805,12 @@ class FederatedShareProviderTest extends \Test\TestCase { ->method('sendRemoteShare') ->willReturn(true); + $result = $this->provider->getAccessList([$file1], true); + $this->assertEquals(['remote' => []], $result); + + $result = $this->provider->getAccessList([$file1], false); + $this->assertEquals(['remote' => false], $result); + $share1 = $this->shareManager->newShare(); $share1->setSharedWith('user@server.com') ->setSharedBy($u1->getUID()) @@ -822,7 +828,6 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->provider->create($share2); $result = $this->provider->getAccessList([$file1], true); - $this->assertEquals(['remote' => [ 'user@server.com' => [ 'token' => 'token1', @@ -833,6 +838,10 @@ class FederatedShareProviderTest extends \Test\TestCase { 'node_id' => $file1->getId(), ], ]], $result); + + $result = $this->provider->getAccessList([$file1], false); + $this->assertEquals(['remote' => true], $result); + $u1->delete(); } } diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 14ed12749b7..0f4a8dd87bc 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -834,6 +834,9 @@ class ShareByMailProvider implements IShareProvider { return $shares; } + /** + * @inheritdoc + */ public function getAccessList($nodes, $currentAccess) { $ids = []; foreach ($nodes as $node) { diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 1b215016ee4..cd0600d3ae9 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -675,6 +675,13 @@ class ShareByMailProviderTest extends TestCase { $folder = $rootFolder->getUserFolder($u1->getUID())->newFolder('foo'); + $accessList = $provider->getAccessList([$folder], true); + $this->assertArrayHasKey('mail', $accessList); + $this->assertFalse($accessList['mail']); + $accessList = $provider->getAccessList([$folder], false); + $this->assertArrayHasKey('mail', $accessList); + $this->assertFalse($accessList['mail']); + $share1 = $this->shareManager->newShare(); $share1->setSharedWith('user@server.com') ->setSharedBy($u1->getUID()) |