diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/ShareBackend/Folder.php | 10 | ||||
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 22 |
2 files changed, 23 insertions, 9 deletions
diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php index 0bb67e49b66..8cd639d047d 100644 --- a/apps/files_sharing/lib/ShareBackend/Folder.php +++ b/apps/files_sharing/lib/ShareBackend/Folder.php @@ -41,6 +41,9 @@ class Folder extends File implements \OCP\Share_Backend_Collection { public function getParents($itemSource, $shareWith = null, $owner = null) { $result = array(); $parent = $this->getParentId($itemSource); + + $userManager = \OC::$server->getUserManager(); + while ($parent) { $shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith, $owner); if ($shares) { @@ -49,8 +52,11 @@ class Folder extends File implements \OCP\Share_Backend_Collection { $share['collection']['path'] = $name; $share['collection']['item_type'] = 'folder'; $share['file_path'] = $name; - $displayNameOwner = \OCP\User::getDisplayName($share['uid_owner']); - $displayNameShareWith = \OCP\User::getDisplayName($share['share_with']); + + $ownerUser = $userManager->get($share['uid_owner']); + $displayNameOwner = $ownerUser === null ? $share['uid_owner'] : $ownerUser->getDisplayName(); + $shareWithUser = $userManager->get($share['share_with']); + $displayNameShareWith = $shareWithUser === null ? $share['share_with'] : $shareWithUser->getDisplayName(); $share['displayname_owner'] = $displayNameOwner ? $displayNameOwner : $share['uid_owner']; $share['share_with_displayname'] = $displayNameShareWith ? $displayNameShareWith : $share['uid_owner']; diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 9911aa37e37..5a165305d58 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -489,13 +489,21 @@ class User_LDAPTest extends TestCase { $this->assertEquals(0, count($result)); } + private function getUsers($search = '', $limit = null, $offset = null) { + $users = \OC::$server->getUserManager()->search($search, $limit, $offset); + $uids = array_map(function(IUser $user) { + return $user->getUID(); + }, $users); + return $uids; + } + public function testGetUsersViaAPINoParam() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::getUsers(); + $result = $this->getUsers(); $this->assertEquals(3, count($result)); } @@ -505,7 +513,7 @@ class User_LDAPTest extends TestCase { $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::getUsers('', 1, 2); + $result = $this->getUsers('', 1, 2); $this->assertEquals(1, count($result)); } @@ -515,7 +523,7 @@ class User_LDAPTest extends TestCase { $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::getUsers('', 2, 1); + $result = $this->getUsers('', 2, 1); $this->assertEquals(2, count($result)); } @@ -525,7 +533,7 @@ class User_LDAPTest extends TestCase { $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::getUsers('yo'); + $result = $this->getUsers('yo'); $this->assertEquals(2, count($result)); } @@ -535,7 +543,7 @@ class User_LDAPTest extends TestCase { $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::getUsers('nix'); + $result = $this->getUsers('nix'); $this->assertEquals(0, count($result)); } @@ -1085,11 +1093,11 @@ class User_LDAPTest extends TestCase { ->willReturnCallback(function($uuid) { return $uuid . '1'; }); //with displayName - $result = \OCP\User::getDisplayName('gunslinger'); + $result = \OC::$server->getUserManager()->get('gunslinger')->getDisplayName(); $this->assertEquals('Roland Deschain', $result); //empty displayname retrieved - $result = \OCP\User::getDisplayName('newyorker'); + $result = \OC::$server->getUserManager()->get('newyorker') === null ? 'newyorker' : \OC::$server->getUserManager()->get('newyorker')->getDisplayName(); $this->assertEquals('newyorker', $result); } |