diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-23 23:51:19 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2021-06-17 10:19:07 +0200 |
commit | 095418493ef909d25808d278ee099fb34070c7fb (patch) | |
tree | bf5b5769659b6a4bf434762d8a79c6cf1a54f840 /lib | |
parent | 330b8802f9b4537247e4341e05461e8cf54c405b (diff) | |
download | nextcloud-server-095418493ef909d25808d278ee099fb34070c7fb.tar.gz nextcloud-server-095418493ef909d25808d278ee099fb34070c7fb.zip |
Use proper methods for display name retrieval
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/TemplateLayout.php | 14 | ||||
-rw-r--r-- | lib/private/legacy/OC_User.php | 26 |
2 files changed, 12 insertions, 28 deletions
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 82bd0fd22e7..16d4423838b 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -52,6 +52,7 @@ use OCP\Defaults; use OCP\IConfig; use OCP\IInitialStateService; use OCP\INavigationManager; +use OCP\IUserSession; use OCP\Support\Subscription\IRegistry; use OCP\Util; @@ -121,7 +122,12 @@ class TemplateLayout extends \OC_Template { break; } } - $userDisplayName = \OC_User::getDisplayName(); + + $userDisplayName = false; + $user = \OC::$server->get(IUserSession::class)->getUser(); + if ($user) { + $userDisplayName = $user->getDisplayName(); + } $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', \OC_User::getUser()); @@ -152,7 +158,11 @@ class TemplateLayout extends \OC_Template { \OC_Util::addStyle('guest'); $this->assign('bodyid', 'body-login'); - $userDisplayName = \OC_User::getDisplayName(); + $userDisplayName = false; + $user = \OC::$server->get(IUserSession::class)->getUser(); + if ($user) { + $userDisplayName = $user->getDisplayName(); + } $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', \OC_User::getUser()); } elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) { diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php index dd97fb63e33..f955c5c6938 100644 --- a/lib/private/legacy/OC_User.php +++ b/lib/private/legacy/OC_User.php @@ -329,32 +329,6 @@ class OC_User { } /** - * get the display name of the user currently logged in. - * - * @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) { - $user = \OC::$server->getUserManager()->get($uid); - if ($user) { - return $user->getDisplayName(); - } else { - return $uid; - } - } else { - $user = \OC::$server->getUserSession()->getUser(); - if ($user) { - return $user->getDisplayName(); - } else { - return false; - } - } - } - - /** * Set password * * @param string $uid The username |