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:
commit
6973718fb8
3 changed files with 16 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue