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
|
@ -335,8 +335,10 @@ class Share20OCS {
|
||||||
|
|
||||||
$formatted = [];
|
$formatted = [];
|
||||||
foreach ($shares as $share) {
|
foreach ($shares as $share) {
|
||||||
|
if ($this->canAccessShare($share)) {
|
||||||
$formatted[] = $this->formatShare($share);
|
$formatted[] = $this->formatShare($share);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new \OC_OCS_Result($formatted);
|
return new \OC_OCS_Result($formatted);
|
||||||
}
|
}
|
||||||
|
@ -496,6 +498,11 @@ class Share20OCS {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function canAccessShare(IShare $share) {
|
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
|
// Owner of the file and the sharer of the file can always get share
|
||||||
if ($share->getShareOwner() === $this->currentUser ||
|
if ($share->getShareOwner() === $this->currentUser ||
|
||||||
$share->getSharedBy() === $this->currentUser
|
$share->getSharedBy() === $this->currentUser
|
||||||
|
|
|
@ -760,7 +760,7 @@ class DefaultShareProvider implements IShareProvider {
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($data !== false) {
|
if ($data !== false) {
|
||||||
$share->setPermissions($data['permissions']);
|
$share->setPermissions((int)$data['permissions']);
|
||||||
$share->setTarget($data['file_target']);
|
$share->setTarget($data['file_target']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -981,13 +981,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
|
||||||
$this->assertCount(1, $share);
|
$this->assertCount(1, $share);
|
||||||
|
|
||||||
$share = $share[0];
|
$share = $share[0];
|
||||||
$this->assertEquals($id, $share->getId());
|
$this->assertSame($id, $share->getId());
|
||||||
$this->assertEquals($group, $share->getSharedWith());
|
$this->assertSame($group, $share->getSharedWith());
|
||||||
$this->assertEquals($owner, $share->getShareOwner());
|
$this->assertSame($owner, $share->getShareOwner());
|
||||||
$this->assertEquals($initiator, $share->getSharedBy());
|
$this->assertSame($initiator, $share->getSharedBy());
|
||||||
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
|
$this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
|
||||||
$this->assertEquals(0, $share->getPermissions());
|
$this->assertSame(0, $share->getPermissions());
|
||||||
$this->assertEquals('userTarget', $share->getTarget());
|
$this->assertSame('userTarget', $share->getTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSharesBy() {
|
public function testGetSharesBy() {
|
||||||
|
|
Loading…
Reference in New Issue