Commit ba080c55 authored by Nigel McNie's avatar Nigel McNie
Browse files

Add a notice bar to the top of the page when you are masquerading as another user.

This makes it easy to tell when you are doing this on all pages - not just on pages where the sidebar is visible.
parent 0a7f07f0
......@@ -243,6 +243,7 @@ $string['username'] = 'Username';
$string['preferredname'] = 'Preferred Name';
$string['usernamedescription'] = ' ';
$string['usernamehelp'] = 'The username you have been given to access this system.';
$string['youaremasqueradingas'] = 'You are masquerading as %s.';
$string['yournewpassword'] = 'Your new password';
$string['yournewpasswordagain'] = 'Your new password again';
$string['invalidsesskey'] = 'Invalid session key';
......
......@@ -1793,10 +1793,6 @@ function profile_sideblock() {
'id' => $USER->get('id'),
'profileicon' => $USER->get('profileicon') ? $USER->get('profileicon') : 0,
);
$saveduser = $USER->get('parentuser');
if (!empty($saveduser) && $saveduser->name) {
$data['realuser'] = $saveduser->name;
}
$data['unreadnotifications'] = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
$data['unreadnotificationsmessage'] = $data['unreadnotifications'] == 1 ? get_string('unreadmessage') : get_string('unreadmessages');
$invitedgroups = get_invited_groups();
......
......@@ -436,6 +436,15 @@ EOF;
$smarty->assign('userauthinstance', $USER->lastauthinstance);
$smarty->assign('SIDEBLOCKS', $SIDEBLOCKS);
if ($USER->get('parentuser')) {
$smarty->assign('USERMASQUERADING', true);
$smarty->assign('masqueradedetails', get_string('youaremasqueradingas', 'mahara', display_name($USER)));
$smarty->assign('becomeyouagain',
' <a href="' . hsc($wwwroot) . 'admin/users/changeuser.php?restore=1">'
. get_string('becomeadminagain', 'admin', $USER->get('parentuser')->name)
. '</a>');
}
}
return $smarty;
......
......@@ -39,6 +39,17 @@ body {
padding: 5px 10px;
}
#masquerading-message {
background-color: #f99;
font-weight: bold;
padding: .5em;
}
#masquerading-message img {
float: left;
margin-top: -1px;
padding-right: .5em;
}
.hidden {
display: none;
}
......
......@@ -31,6 +31,7 @@
<link rel="shortcut icon" href="{$WWWROOT}favicon.ico" type="image/vnd.microsoft.icon">
</head>
<body>
{if $USERMASQUERADING}<div id="masquerading-message"><img src="{theme_path location='images/icon_problem.gif'}" alt="">{$masqueradedetails} {$becomeyouagain}</div>{/if}
<div id="container">
<div id="loading_box" class="hidden"></div>
<div id="topwrapper">
......
......@@ -65,10 +65,6 @@
<a href="{$WWWROOT}?logout" id="btn-logout">{str tag="logout"}</a>
<a href="{$WWWROOT}account/" id="btn-settings">{str tag="settings"}</a>
</div>
{if $data.realuser}
<div id="changeuser">
<a href="{$WWWROOT}admin/users/changeuser.php?restore=1">{str tag=becomeadminagain section=admin args=$data.realuser}</a>
</div>
{/if}
{if $USERMASQUERADING}<div id="changeuser">{$becomeyouagain}</div>{/if}
{* This makes sure the profile block still appears to contain the profile image, even if the profile block is pretty much empty otherwise *}
<div class="cb"></div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment