Get proper accesslist for userFolder

If the accesslist is requested for a users root folder we should
properly construct the path

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2017-04-19 15:11:54 +02:00
parent a3569a1452
commit ae2db5e60d
No known key found for this signature in database
GPG key ID: F941078878347C0C
2 changed files with 8 additions and 4 deletions

View file

@ -1233,7 +1233,7 @@ class Manager implements IManager {
//Get node for the owner //Get node for the owner
$userFolder = $this->rootFolder->getUserFolder($owner); $userFolder = $this->rootFolder->getUserFolder($owner);
if (!$userFolder->isSubNode($path)) { if ($path->getId() !== $userFolder->getId() && !$userFolder->isSubNode($path)) {
$path = $userFolder->getById($path->getId())[0]; $path = $userFolder->getById($path->getId())[0];
} }
@ -1245,7 +1245,12 @@ class Manager implements IManager {
if ($currentAccess) { if ($currentAccess) {
$ownerPath = $path->getPath(); $ownerPath = $path->getPath();
list(, , , $ownerPath) = explode('/', $ownerPath, 4); $ownerPath = explode('/', $ownerPath, 4);
if (count($ownerPath) < 4) {
$ownerPath = '';
} else {
$ownerPath = $ownerPath[3];
}
$al['users'][$owner] = [ $al['users'][$owner] = [
'node_id' => $path->getId(), 'node_id' => $path->getId(),
'node_path' => '/' . $ownerPath, 'node_path' => '/' . $ownerPath,

View file

@ -2767,8 +2767,7 @@ class ManagerTest extends \Test\TestCase {
$node->expects($this->once()) $node->expects($this->once())
->method('getOwner') ->method('getOwner')
->willReturn($owner); ->willReturn($owner);
$node->expects($this->once()) $node->method('getId')
->method('getId')
->willReturn(42); ->willReturn(42);
$userFolder = $this->createMock(Folder::class); $userFolder = $this->createMock(Folder::class);