Fix default share provider
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
2fcf334c6a
commit
5b57bb955b
|
@ -1128,17 +1128,18 @@ class DefaultShareProvider implements IShareProvider {
|
||||||
}
|
}
|
||||||
} else if ($type === \OCP\Share::SHARE_TYPE_LINK) {
|
} else if ($type === \OCP\Share::SHARE_TYPE_LINK) {
|
||||||
$link = true;
|
$link = true;
|
||||||
} else if ($type === self::SHARE_TYPE_USERGROUP) {
|
} else if ($type === self::SHARE_TYPE_USERGROUP && $currentAccess === true) {
|
||||||
if ($currentAccess === true) {
|
$uid = $row['share_with'];
|
||||||
$uid = $row['share_with'];
|
$users[$uid] = isset($users[$uid]) ? $users[$uid] : [];
|
||||||
$users[$uid] = isset($users[$uid]) ? $users[$uid] : [];
|
$users[$uid][$row['id']] = $row;
|
||||||
$users[$uid][$row['id']] = $row;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$cursor->closeCursor();
|
$cursor->closeCursor();
|
||||||
|
|
||||||
$users = array_map([$this, 'filterSharesOfUser'], $users);
|
$users = array_map([$this, 'filterSharesOfUser'], $users);
|
||||||
|
if ($currentAccess === true) {
|
||||||
|
$users = array_filter($users);
|
||||||
|
}
|
||||||
|
|
||||||
return ['users' => $users, 'public' => $link];
|
return ['users' => $users, 'public' => $link];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1545,9 +1545,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
|
||||||
$this->assertEquals(1, $stmt);
|
$this->assertEquals(1, $stmt);
|
||||||
$id = $qb->getLastInsertId();
|
$id = $qb->getLastInsertId();
|
||||||
|
|
||||||
$user1 = $this->getMock('\OCP\IUser');
|
$user1 = $this->createMock(IUser::class);
|
||||||
$user1->method('getUID')->willReturn('user1');
|
$user1->method('getUID')->willReturn('user1');
|
||||||
$user2 = $this->getMock('\OCP\IUser');
|
$user2 = $this->createMock(IUser::class);
|
||||||
$user2->method('getUID')->willReturn('user2');
|
$user2->method('getUID')->willReturn('user2');
|
||||||
$this->userManager->method('get')->will($this->returnValueMap([
|
$this->userManager->method('get')->will($this->returnValueMap([
|
||||||
['user1', $user1],
|
['user1', $user1],
|
||||||
|
@ -1556,7 +1556,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
|
||||||
|
|
||||||
$this->groupManager->method('get')->with('group')->willReturn(null);
|
$this->groupManager->method('get')->with('group')->willReturn(null);
|
||||||
|
|
||||||
$file = $this->getMock('\OCP\Files\File');
|
$file = $this->createMock(File::class);
|
||||||
$file->method('getId')->willReturn(1);
|
$file->method('getId')->willReturn(1);
|
||||||
|
|
||||||
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
|
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
|
||||||
|
@ -2503,10 +2503,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
|
||||||
$result = $provider->getAccessList([$folder1, $folder2, $file1], false);
|
$result = $provider->getAccessList([$folder1, $folder2, $file1], false);
|
||||||
|
|
||||||
$this->assertCount(4, $result['users']);
|
$this->assertCount(4, $result['users']);
|
||||||
$this->assertContains('testShare2', $result['users']);
|
$this->assertArrayHasKey('testShare2', $result['users']);
|
||||||
$this->assertContains('testShare3', $result['users']);
|
$this->assertArrayHasKey('testShare3', $result['users']);
|
||||||
$this->assertContains('testShare4', $result['users']);
|
$this->assertArrayHasKey('testShare4', $result['users']);
|
||||||
$this->assertContains('testShare5', $result['users']);
|
$this->assertArrayHasKey('testShare5', $result['users']);
|
||||||
$this->assertTrue($result['public']);
|
$this->assertTrue($result['public']);
|
||||||
|
|
||||||
$provider->delete($share1);
|
$provider->delete($share1);
|
||||||
|
@ -2590,9 +2590,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
|
||||||
$result = $provider->getAccessList([$folder1, $folder2, $file1], true);
|
$result = $provider->getAccessList([$folder1, $folder2, $file1], true);
|
||||||
|
|
||||||
$this->assertCount(3, $result['users']);
|
$this->assertCount(3, $result['users']);
|
||||||
$this->assertContains('testShare2', $result['users']);
|
$this->assertArrayHasKey('testShare2', $result['users']);
|
||||||
$this->assertContains('testShare3', $result['users']);
|
$this->assertArrayHasKey('testShare3', $result['users']);
|
||||||
$this->assertContains('testShare5', $result['users']);
|
$this->assertArrayHasKey('testShare5', $result['users']);
|
||||||
$this->assertTrue($result['public']);
|
$this->assertTrue($result['public']);
|
||||||
|
|
||||||
$provider->delete($share1);
|
$provider->delete($share1);
|
||||||
|
|
Loading…
Reference in New Issue