summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/lib/ShareBackend/Folder.php10
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php4
-rw-r--r--lib/private/Share/Share.php6
-rw-r--r--lib/private/legacy/user.php2
-rw-r--r--lib/public/User.php12
5 files changed, 16 insertions, 18 deletions
diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php
index c48a26300a2..0930f30eea7 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 270e3eedbfd..2b5952c9742 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -1094,11 +1094,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')->getDisplayName();
$this->assertEquals('newyorker', $result);
}
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index 90a05ac51a8..4211d6c8fc2 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -1238,7 +1238,8 @@ class Share extends Constants {
$row['share_with_displayname'] = $row['share_with'];
if ( isset($row['share_with']) && $row['share_with'] != '' &&
$row['share_type'] === self::SHARE_TYPE_USER) {
- $row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']);
+ $shareWithUser = \OC::$server->getUserManager()->get($row['share_with']);
+ $row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName();
} else if(isset($row['share_with']) && $row['share_with'] != '' &&
$row['share_type'] === self::SHARE_TYPE_REMOTE) {
$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']);
@@ -1251,7 +1252,8 @@ class Share extends Constants {
}
}
if ( isset($row['uid_owner']) && $row['uid_owner'] != '') {
- $row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']);
+ $ownerUser = \OC::$server->get($row['uid_owner']);
+ $row['displayname_owner'] = $ownerUser === null ? $row['uid_owner'] : $ownerUser->getDisplayName();
}
if ($row['permissions'] > 0) {
diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php
index 07aa5a92f9a..9c877f22a46 100644
--- a/lib/private/legacy/user.php
+++ b/lib/private/legacy/user.php
@@ -312,6 +312,8 @@ class OC_User {
*
* @param string $uid
* @return string|bool uid or false
+ * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method
+ * get() of \OCP\IUserManager - \OC::$server->getUserManager()
*/
public static function getDisplayName($uid = null) {
if ($uid) {
diff --git a/lib/public/User.php b/lib/public/User.php
index 6e4e1d52a72..ba9039054be 100644
--- a/lib/public/User.php
+++ b/lib/public/User.php
@@ -58,18 +58,6 @@ class User {
}
/**
- * Get the user display name of the user currently logged in.
- * @param string|null $user user id or null for current user
- * @return string display name
- * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method
- * get() of \OCP\IUserManager - \OC::$server->getUserManager()
- * @since 5.0.0
- */
- public static function getDisplayName( $user = null ) {
- return \OC_User::getDisplayName( $user );
- }
-
- /**
* Check if the user is logged in
* @return boolean
* @since 5.0.0