mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
Merge branch 'MDL-45893-master-v2' of git://github.com/jethac/moodle
Conflicts: theme/bootstrapbase/style/moodle.css
This commit is contained in:
commit
f03b612191
@ -1034,6 +1034,7 @@ $string['locktimeout'] = 'The operation timed out while waiting for a lock.';
|
||||
$string['log_excel_date_format'] = 'yyyy mmmm d h:mm';
|
||||
$string['loggedinas'] = 'You are logged in as {$a}';
|
||||
$string['loggedinasguest'] = 'You are currently using guest access';
|
||||
$string['loggedinfrom'] = 'from {$a}';
|
||||
$string['loggedinnot'] = 'You are not logged in.';
|
||||
$string['login'] = 'Log in';
|
||||
$string['loginalready'] = 'You are already logged in';
|
||||
@ -1548,6 +1549,7 @@ $string['rolemappings'] = 'Role mappings';
|
||||
$string['rolerenaming'] = 'Role renaming';
|
||||
$string['rolerenaming_help'] = 'This setting allows the displayed names for roles used in the course to be changed. Only the displayed name is changed - role permissions are not affected. New role names will appear on the course participants page and elsewhere within the course. If the renamed role is one that the administrator has selected as a course manager role, then the new role name will also appear as part of the course listings.';
|
||||
$string['roles'] = 'Roles';
|
||||
$string['roleviewas'] = 'You are viewing as a {$a}';
|
||||
$string['rss'] = 'RSS';
|
||||
$string['rssarticles'] = 'Number of RSS recent articles';
|
||||
$string['rsserror'] = 'Error reading RSS data';
|
||||
@ -1905,6 +1907,7 @@ $string['usernamenotfound'] = 'The username was not found in the database';
|
||||
$string['usernameoremail'] = 'Enter either username or email address';
|
||||
$string['usernotconfirmed'] = 'Could not confirm {$a}';
|
||||
$string['userpic'] = 'User picture';
|
||||
$string['userrevert'] = 'Revert to your own account';
|
||||
$string['users'] = 'Users';
|
||||
$string['userselectorautoselectunique'] = 'If only one user matches the search, select them automatically';
|
||||
$string['userselectorpreserveselected'] = 'Keep selected users, even if they no longer match the search';
|
||||
|
@ -2904,6 +2904,137 @@ EOD;
|
||||
return html_writer::tag('ul', implode("\n", $lis), $attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a user menu, returning HTML that can be echoed out by a
|
||||
* layout file.
|
||||
*
|
||||
* @param stdClass $user A user object, usually $USER.
|
||||
* @param bool $withlinks true if a dropdown should be built.
|
||||
* @return string HTML fragment.
|
||||
*/
|
||||
public function user_menu($user = null, $withlinks = null) {
|
||||
global $USER, $CFG;
|
||||
|
||||
if (is_null($user)) {
|
||||
$user = $USER;
|
||||
}
|
||||
|
||||
// Note: this behaviour is intended to match that of core_renderer::login_info,
|
||||
// but should not be considered to be good practice; layout options are
|
||||
// intended to be theme-specific. Please don't copy this snippet anywhere else.
|
||||
if (is_null($withlinks)) {
|
||||
$withlinks = empty($this->page->layout_options['nologinlinks']);
|
||||
}
|
||||
|
||||
$returnstr = "";
|
||||
|
||||
// If during initial install, return the empty return string.
|
||||
if (during_initial_install()) {
|
||||
return $returnstr;
|
||||
}
|
||||
|
||||
// If not logged in, show the typical not-logged-in string.
|
||||
if (!isloggedin()) {
|
||||
$returnstr = get_string('loggedinnot', 'moodle');
|
||||
$loginpage = ((string)$this->page->url === get_login_url());
|
||||
if (!$loginpage) {
|
||||
$loginurl = get_login_url();
|
||||
$returnstr .= " (<a href=\"$loginurl\">" . get_string('login') . '</a>)';
|
||||
}
|
||||
return html_writer::tag(
|
||||
'span',
|
||||
$returnstr
|
||||
);
|
||||
}
|
||||
|
||||
// Get some navigation opts.
|
||||
require_once($CFG->dirroot . '/user/lib.php');
|
||||
$opts = user_get_user_navigation_info($user, $this->page, $this->page->course);
|
||||
|
||||
$avatarclasses = "avatars";
|
||||
$avatarcontents = html_writer::span($opts->metadata['useravatar'], 'avatar current');
|
||||
$usertextcontents = $opts->metadata['userfullname'];
|
||||
|
||||
// Other user.
|
||||
if ($opts->metadata['asotheruser']) {
|
||||
$avatarcontents .= html_writer::span(
|
||||
$opts->metadata['realuseravatar'],
|
||||
'avatar realuser'
|
||||
);
|
||||
$usertextcontents = $opts->metadata['realuserfullname'];
|
||||
$usertextcontents .= html_writer::tag(
|
||||
'span',
|
||||
get_string(
|
||||
'loggedinas',
|
||||
'moodle',
|
||||
html_writer::span(
|
||||
$opts->metadata['userfullname'],
|
||||
'value'
|
||||
)
|
||||
),
|
||||
array('class' => 'meta viewingas')
|
||||
);
|
||||
}
|
||||
|
||||
// Role.
|
||||
if ($opts->metadata['asotherrole']) {
|
||||
$role = core_text::strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['rolename'])));
|
||||
$usertextcontents .= html_writer::span(
|
||||
get_string(
|
||||
'roleviewas',
|
||||
'moodle',
|
||||
html_writer::span(
|
||||
$opts->metadata['rolename'],
|
||||
'value'
|
||||
)
|
||||
),
|
||||
'meta role role-' . $role
|
||||
);
|
||||
}
|
||||
|
||||
// MNet.
|
||||
if ($opts->metadata['asmnetuser']) {
|
||||
$mnet = strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['mnetidprovidername'])));
|
||||
$usertextcontents .= html_writer::span(
|
||||
get_string(
|
||||
'loggedinfrom',
|
||||
'moodle',
|
||||
html_writer::span(
|
||||
$opts->metadata['mnetidprovidername'],
|
||||
'value'
|
||||
)
|
||||
),
|
||||
'meta mnet mnet-' . $mnet
|
||||
);
|
||||
}
|
||||
|
||||
$returnstr .= html_writer::span(
|
||||
html_writer::span($avatarcontents, $avatarclasses) . html_writer::span($usertextcontents, 'usertext'),
|
||||
'userbutton'
|
||||
);
|
||||
|
||||
$am = new action_menu();
|
||||
$am->initialise_js($this->page);
|
||||
$am->set_menu_trigger($returnstr);
|
||||
$am->set_alignment(action_menu::TR, action_menu::BR);
|
||||
if ($withlinks) {
|
||||
foreach ($opts->navitems as $key => $value) {
|
||||
$al = new action_menu_link_secondary(
|
||||
$value->url,
|
||||
new pix_icon($value->pix, $value->title, null),
|
||||
$value->title,
|
||||
array('class' => 'icon')
|
||||
);
|
||||
$am->add($al);
|
||||
}
|
||||
}
|
||||
|
||||
return html_writer::div(
|
||||
$this->render($am),
|
||||
'usermenu'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the navbar content so that it can be echoed out by the layout
|
||||
*
|
||||
|
@ -66,7 +66,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<div id="page-header" class="clearfix">
|
||||
<h1 class="headermain"><?php echo $PAGE->heading ?></h1>
|
||||
<div class="headermenu"><?php
|
||||
echo $OUTPUT->login_info();
|
||||
echo $OUTPUT->user_menu();
|
||||
echo $OUTPUT->lang_menu();
|
||||
echo $PAGE->headingmenu;
|
||||
?></div>
|
||||
|
@ -80,9 +80,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php if ($hasheading) { ?>
|
||||
<h1 class="headermain"><?php echo $PAGE->heading ?></h1>
|
||||
<div class="headermenu"><?php
|
||||
if ($haslogininfo) {
|
||||
echo $OUTPUT->login_info();
|
||||
}
|
||||
echo $OUTPUT->user_menu();
|
||||
if (!empty($PAGE->layout_options['langmenu'])) {
|
||||
echo $OUTPUT->lang_menu();
|
||||
}
|
||||
|
@ -192,6 +192,94 @@ a.skip:active {position: static;display: block;}
|
||||
.headermenu {float:right;margin:10px;font-size:0.8em;text-align:right;}
|
||||
#course-header {clear:both;}
|
||||
|
||||
/**
|
||||
* User menu
|
||||
*/
|
||||
.usermenu {
|
||||
border: 1px solid #333;
|
||||
padding: 4px 6px;
|
||||
margin: 0.5em 0em;
|
||||
}
|
||||
.usermenu .toggle-display {
|
||||
outline: none;
|
||||
}
|
||||
.usermenu .userbutton {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
display: inline-block;
|
||||
font-size: 15px;
|
||||
}
|
||||
.usermenu .userbutton > * {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.usermenu .userbutton .avatars {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.usermenu .userbutton .usertext {
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
}
|
||||
.usermenu .userbutton .usertext .meta{
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
}
|
||||
.usermenu .userbutton .usertext .meta .value {
|
||||
font-weight: bold;
|
||||
}
|
||||
.usermenu .moodle-actionmenu .toggle-display.textmenu .caret {
|
||||
display: none;
|
||||
}
|
||||
.jsenabled .usermenu .moodle-actionmenu[data-enhanced] .toggle-display.textmenu {
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
.jsenabled.dir-rtl .usermenu .moodle-actionmenu[data-enhanced] .toggle-display.textmenu {
|
||||
margin-right: 0;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.jsenabled .usermenu .moodle-actionmenu[data-enhanced] .toggle-display.textmenu .caret {
|
||||
display: inline-block;
|
||||
margin-top: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.userloggedinas .usermenu .userbutton .avatars .avatar {
|
||||
display: inline-block;
|
||||
vertical-align:middle;
|
||||
overflow: hidden;
|
||||
}
|
||||
.userloggedinas .usermenu .userbutton .avatars .avatar img {
|
||||
width: inherit;
|
||||
height: inherit;
|
||||
}
|
||||
.userloggedinas .usermenu .userbutton .avatars .avatar.current {
|
||||
position: relative;
|
||||
top: 4px;
|
||||
left: 4px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-top: 11px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 10px;
|
||||
box-shadow: -2px -2px 16px rgba(0,0,0,0.25);
|
||||
}
|
||||
.dir-ltr .usermenu .userbutton .avatars {
|
||||
margin-right: 6px;
|
||||
}
|
||||
.dir-rtl .usermenu .userbutton {
|
||||
margin-right: -4px;
|
||||
}
|
||||
.dir-rtl .usermenu .userbutton .avatars {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.dir-ltr.userloggedinas .usermenu .userbutton .avatars .avatar.current {
|
||||
margin-right: -34px;
|
||||
}
|
||||
.dir-rtl.userloggedinas .usermenu .userbutton .avatars .avatar.current {
|
||||
margin-left: -22px;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navbar
|
||||
*/
|
||||
|
@ -50,7 +50,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php echo $OUTPUT->custom_menu(); ?>
|
||||
<ul class="nav pull-right">
|
||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,7 +51,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php echo $OUTPUT->custom_menu(); ?>
|
||||
<ul class="nav pull-right">
|
||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -56,7 +56,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php echo $OUTPUT->custom_menu(); ?>
|
||||
<ul class="nav pull-right">
|
||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu(); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -60,7 +60,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php echo $OUTPUT->custom_menu(); ?>
|
||||
<ul class="nav pull-right">
|
||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu(); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -75,6 +75,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<div class="breadcrumb-button"><?php echo $OUTPUT->page_heading_button(); ?></div>
|
||||
</div>
|
||||
<?php echo $OUTPUT->page_heading(); ?>
|
||||
<?php echo $OUTPUT->user_menu(); ?>
|
||||
<div id="course-header">
|
||||
<?php echo $OUTPUT->course_header(); ?>
|
||||
</div>
|
||||
|
@ -340,3 +340,101 @@ div#dock {
|
||||
border-right: 0px none;
|
||||
}
|
||||
}
|
||||
|
||||
// Usermenu
|
||||
.usermenu {
|
||||
> .moodle-actionmenu > .menubar {
|
||||
display: block;
|
||||
margin: 2px 0px;
|
||||
li {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.toggle-display {
|
||||
color: #777;
|
||||
outline: none;
|
||||
}
|
||||
.userbutton {
|
||||
.avatars{
|
||||
display: inline-block;
|
||||
height: 35px;
|
||||
vertical-align: middle;
|
||||
margin-right: 6px;
|
||||
}
|
||||
.usertext {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
line-height: 1em;
|
||||
.meta {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
.value {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.moodle-actionmenu[data-enhanced].show .menu a {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.userloggedinas .usermenu .userbutton .avatars {
|
||||
.avatar {
|
||||
&.current {
|
||||
position: relative;
|
||||
top: 4px;
|
||||
left: 4px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-top: 11px;
|
||||
border: 1px solid #fff;
|
||||
border-radius: 50%;
|
||||
box-shadow: -2px -2px 16px rgba(0,0,0,0.25);
|
||||
}
|
||||
img {
|
||||
width: inherit;
|
||||
height: inherit;
|
||||
}
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
.jsenabled .usermenu .moodle-actionmenu[data-enhanced] .toggle-display.textmenu .caret {
|
||||
margin-top: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.dir-ltr {
|
||||
.usermenu {
|
||||
.userbutton {
|
||||
margin-right: 4px;
|
||||
.avatars{
|
||||
margin-right: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.userloggedinas .usermenu .userbutton .avatars {
|
||||
.avatar {
|
||||
&.current {
|
||||
margin-right: -34px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dir-rtl {
|
||||
.usermenu {
|
||||
.userbutton {
|
||||
margin-left: 4px;
|
||||
.avatars{
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.userloggedinas .usermenu .userbutton .avatars {
|
||||
.avatar {
|
||||
&.current {
|
||||
margin-left: -22px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -440,6 +440,18 @@
|
||||
}
|
||||
.nav-collapse.active {
|
||||
height: auto;
|
||||
.usermenu .moodle-actionmenu[data-enhanced] {
|
||||
.toggle-display {
|
||||
display: none;
|
||||
}
|
||||
.menu {
|
||||
display: block;
|
||||
|
||||
li {
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.path-mod-data .box > table > tbody > tr > td {
|
||||
display: block;
|
||||
|
File diff suppressed because one or more lines are too long
@ -53,7 +53,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php echo $OUTPUT->custom_menu(); ?>
|
||||
<ul class="nav pull-right">
|
||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -54,7 +54,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php echo $OUTPUT->custom_menu(); ?>
|
||||
<ul class="nav pull-right">
|
||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -65,7 +65,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<?php echo $OUTPUT->custom_menu(); ?>
|
||||
<ul class="nav pull-right">
|
||||
<li><?php echo $OUTPUT->page_heading_menu(); ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
|
||||
<li class="navbar-text"><?php echo $OUTPUT->user_menu() ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
164
user/lib.php
164
user/lib.php
@ -614,3 +614,167 @@ function user_count_login_failures($user, $reset = true) {
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of essential user navigation items.
|
||||
*
|
||||
* @param stdclass $user user object.
|
||||
* @param moodle_page $page page object.
|
||||
* @return stdClass $returnobj navigation information object, where:
|
||||
*
|
||||
* $returnobj->navitems array array of links where each link is a
|
||||
* stdClass with fields url, title, and
|
||||
* pix
|
||||
* $returnobj->metadata array array of useful user metadata to be
|
||||
* used when constructing navigation;
|
||||
* fields include:
|
||||
*
|
||||
* ROLE FIELDS
|
||||
* asotherrole bool whether viewing as another role
|
||||
* rolename string name of the role
|
||||
*
|
||||
* USER FIELDS
|
||||
* These fields are for the currently-logged in user, or for
|
||||
* the user that the real user is currently logged in as.
|
||||
*
|
||||
* userid int the id of the user in question
|
||||
* userfullname string the user's full name
|
||||
* userprofileurl moodle_url the url of the user's profile
|
||||
* useravatar string a HTML fragment - the rendered
|
||||
* user_picture for this user
|
||||
*
|
||||
* "REAL USER" FIELDS
|
||||
* These fields are for when asotheruser is true, and
|
||||
* correspond to the underlying "real user".
|
||||
*
|
||||
* asotheruser bool whether viewing as another user
|
||||
* realuserid int the id of the user in question
|
||||
* realuserfullname string the user's full name
|
||||
* realuserprofileurl moodle_url the url of the user's profile
|
||||
* realuseravatar string a HTML fragment - the rendered
|
||||
* user_picture for this user
|
||||
*
|
||||
* MNET PROVIDER FIELDS
|
||||
* asmnetuser bool whether viewing as a user from an
|
||||
* MNet provider
|
||||
* mnetidprovidername string name of the MNet provider
|
||||
* mnetidproviderwwwroot string URL of the MNet provider
|
||||
*/
|
||||
function user_get_user_navigation_info($user, $page) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
$returnobject = new stdClass();
|
||||
$returnobject->navitems = array();
|
||||
$returnobject->metadata = array();
|
||||
|
||||
$course = $page->course;
|
||||
|
||||
// Query the environment.
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
// Get basic user metadata.
|
||||
$returnobject->metadata['userid'] = $user->id;
|
||||
$returnobject->metadata['userfullname'] = fullname($user, true);
|
||||
$returnobject->metadata['userprofileurl'] = new moodle_url('/user/profile.php', array(
|
||||
'id' => $user->id
|
||||
));
|
||||
$returnobject->metadata['useravatar'] = $OUTPUT->user_picture ($user, array('link' => false));
|
||||
|
||||
if (isguestuser()) {
|
||||
|
||||
// Build a list of items for a guest.
|
||||
$login = new stdClass();
|
||||
$login->url = get_login_url();
|
||||
$login->title = get_string('login');
|
||||
$returnobject->navitems[] = $login;
|
||||
|
||||
} else {
|
||||
// Build a list of items for a regular user.
|
||||
|
||||
// Query MNet status.
|
||||
if ($returnobject->metadata['asmnetuser'] = is_mnet_remote_user($user)) {
|
||||
$mnetidprovider = $DB->get_record('mnet_host', array('id' => $user->mnethostid));
|
||||
$returnobject->metadata['mnetidprovidername'] = $mnetidprovider->name;
|
||||
$returnobject->metadata['mnetidproviderwwwroot'] = $mnetidprovider->wwwroot;
|
||||
}
|
||||
|
||||
// Links: My Profile.
|
||||
$myprofile = new stdClass();
|
||||
$myprofile->url = new moodle_url('/user/profile.php', array('id' => $user->id));
|
||||
$myprofile->title = get_string('myprofile');
|
||||
$myprofile->pix = "i/user";
|
||||
$returnobject->navitems[] = $myprofile;
|
||||
|
||||
// Links: My Home.
|
||||
$myhome = new stdClass();
|
||||
$myhome->url = new moodle_url('/my/');
|
||||
$myhome->title = get_string('mymoodle', 'admin');
|
||||
$myhome->pix = "i/course";
|
||||
$returnobject->navitems[] = $myhome;
|
||||
|
||||
// Links: Role-return or logout link.
|
||||
$lastobj = null;
|
||||
$buildlogout = true;
|
||||
$returnobject->metadata['asotherrole'] = false;
|
||||
if (is_role_switched($course->id)) {
|
||||
if ($role = $DB->get_record('role', array('id' => $user->access['rsw'][$context->path]))) {
|
||||
// Build role-return link instead of logout link.
|
||||
$rolereturn = new stdClass();
|
||||
$rolereturn->url = new moodle_url('/course/switchrole.php', array(
|
||||
'id' => $course->id,
|
||||
'sesskey' => sesskey(),
|
||||
'switchrole' => 0,
|
||||
'returnurl' => $PAGE->url->out_as_local_url(false)
|
||||
));
|
||||
$rolereturn->pix = "a/logout";
|
||||
$rolereturn->title = get_string('switchrolereturn');
|
||||
$lastobj = $rolereturn;
|
||||
|
||||
$returnobject->metadata['asotherrole'] = true;
|
||||
$returnobject->metadata['rolename'] = role_get_name($role, $context);
|
||||
|
||||
$buildlogout = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnobject->metadata['asotheruser'] = \core\session\manager::is_loggedinas()) {
|
||||
$realuser = \core\session\manager::get_realuser();
|
||||
|
||||
// Save values for the real user, as $user will be full of data for the
|
||||
// user the user is disguised as.
|
||||
$returnobject->metadata['realuserid'] = $realuser->id;
|
||||
$returnobject->metadata['realuserfullname'] = fullname($realuser, true);
|
||||
$returnobject->metadata['realuserprofileurl'] = new moodle_url('/user/profile.php', array(
|
||||
'id' => $realuser->id
|
||||
));
|
||||
$returnobject->metadata['realuseravatar'] = $OUTPUT->user_picture ($realuser, array('link' => false));
|
||||
|
||||
// Build a user-revert link.
|
||||
$userrevert = new stdClass();
|
||||
$userrevert->url = new moodle_url('/course/loginas.php', array(
|
||||
'id' => $course->id,
|
||||
'sesskey' => sesskey()
|
||||
));
|
||||
$userrevert->pix = "a/logout";
|
||||
$userrevert->title = get_string('userrevert');
|
||||
$lastobj = $userrevert;
|
||||
|
||||
$buildlogout = false;
|
||||
}
|
||||
|
||||
if ($buildlogout) {
|
||||
// Build a logout link.
|
||||
$logout = new stdClass();
|
||||
$logout->url = new moodle_url('/login/logout.php', array('sesskey' => sesskey()));
|
||||
$logout->pix = "a/logout";
|
||||
$logout->title = get_string('logout');
|
||||
$lastobj = $logout;
|
||||
}
|
||||
|
||||
// Add the last item to the list.
|
||||
if (!is_null($lastobj)) {
|
||||
$returnobject->navitems[] = $lastobj;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnobject;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user