Merge pull request #21940 from owncloud/share2_do_not_returned_removed_group_shares

[Share 2.0] Properly handle user deleted group shares
This commit is contained in:
Thomas Müller 2016-01-27 16:16:06 +01:00
commit 6973718fb8
3 changed files with 16 additions and 9 deletions

View file

@ -335,7 +335,9 @@ class Share20OCS {
$formatted = [];
foreach ($shares as $share) {
$formatted[] = $this->formatShare($share);
if ($this->canAccessShare($share)) {
$formatted[] = $this->formatShare($share);
}
}
return new \OC_OCS_Result($formatted);
@ -496,6 +498,11 @@ class Share20OCS {
* @return bool
*/
protected function canAccessShare(IShare $share) {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
}
// Owner of the file and the sharer of the file can always get share
if ($share->getShareOwner() === $this->currentUser ||
$share->getSharedBy() === $this->currentUser

View file

@ -760,7 +760,7 @@ class DefaultShareProvider implements IShareProvider {
$stmt->closeCursor();
if ($data !== false) {
$share->setPermissions($data['permissions']);
$share->setPermissions((int)$data['permissions']);
$share->setTarget($data['file_target']);
}

View file

@ -981,13 +981,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals($id, $share->getId());
$this->assertEquals($group, $share->getSharedWith());
$this->assertEquals($owner, $share->getShareOwner());
$this->assertEquals($initiator, $share->getSharedBy());
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
$this->assertEquals(0, $share->getPermissions());
$this->assertEquals('userTarget', $share->getTarget());
$this->assertSame($id, $share->getId());
$this->assertSame($group, $share->getSharedWith());
$this->assertSame($owner, $share->getShareOwner());
$this->assertSame($initiator, $share->getSharedBy());
$this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
$this->assertSame(0, $share->getPermissions());
$this->assertSame('userTarget', $share->getTarget());
}
public function testGetSharesBy() {