Skip to content

Commit 11a5126

Browse files
pkp#11044 [stable-3_5_0] Display user initials on the top navbar (pkp#11066)
* pkp#11044 Assign originalUser when user is logged in as someone else * pkp#11044 Display user initials instead of user icon in top navigation * pkp#11044 Use var loggedInAsUser instead of originalUser
1 parent 69449c5 commit 11a5126

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

classes/template/PKPTemplateManager.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,22 @@ public function initialize(PKPRequest $request)
406406
* database is executed (e.g., when loading installer pages).
407407
*/
408408
if (!PKPSessionGuard::isSessionDisable()) {
409+
$loggedInAsUserId = Validation::loggedInAs();
410+
409411
$this->assign([
410412
'isUserLoggedIn' => Validation::isLoggedIn(),
411-
'isUserLoggedInAs' => (bool) Validation::loggedInAs(),
413+
'isUserLoggedInAs' => (bool) $loggedInAsUserId,
412414
'itemsPerPage' => Config::getVar('interface', 'items_per_page'),
413415
'numPageLinks' => Config::getVar('interface', 'page_links'),
414416
'siteTitle' => $request->getSite()->getLocalizedData('title'),
415417
]);
416418

419+
if ($loggedInAsUserId) {
420+
$this->assign([
421+
'loggedInAsUser' => Repo::user()->get($loggedInAsUserId)
422+
]);
423+
}
424+
417425
$user = $request->getUser();
418426
if ($user) {
419427
$unreadNotificationCount = Notification::withRead(false)

templates/layouts/backend.tpl

+10-2
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,28 @@
8585
</div>
8686
<dropdown class="app__headerAction app__userNav">
8787
<template #button>
88+
{if $isUserLoggedInAs}
89+
{assign var="activeUser" value=$loggedInAsUser}
90+
{else}
91+
{assign var="activeUser" value=$currentUser}
92+
{/if}
8893
<initials-avatar
94+
initials="{$activeUser->getDisplayInitials()|escape}"
8995
:is-secondary="true"
9096
{if $isUserLoggedInAs}
9197
:is-disabled="true"
9298
{/if}
9399
></initials-avatar>
100+
<span class="-screenReader">"{$activeUser->getData('userName')|escape}"</span>
94101
{if $isUserLoggedInAs}
95102
<initials-avatar
96-
class="absolute right-2 top-2 rounded-full h-5 w-5"
103+
initials="{$currentUser->getDisplayInitials()|escape}"
104+
class="absolute right-2 top-0 rounded-full h-5 w-5"
97105
:is-warnable="true"
98106
:shrink="true"
99107
></initials-avatar>
108+
<span class="-screenReader">{$currentUser->getData('userName')|escape}</span>
100109
{/if}
101-
<span class="-screenReader">{$currentUser->getData('userName')}</span>
102110
</template>
103111
<nav aria-label="{translate key="common.navigation.user"}">
104112
{if $supportedLocales|@count > 1}

0 commit comments

Comments
 (0)