mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-57001 user_menu: Hide switch roles students
Check that there are switchable roles before showing the link in the user menu.
This commit is contained in:
parent
22b8c5b842
commit
7dba450fd4
27
user/lib.php
27
user/lib.php
@ -929,18 +929,21 @@ function user_get_user_navigation_info($user, $page, $options = array()) {
|
||||
|
||||
}
|
||||
} else {
|
||||
// Build role-return link instead of logout link.
|
||||
$switchrole = new stdClass();
|
||||
$switchrole->itemtype = 'link';
|
||||
$switchrole->url = new moodle_url('/course/switchrole.php', array(
|
||||
'id' => $course->id,
|
||||
'switchrole' => -1,
|
||||
'returnurl' => $page->url->out_as_local_url(false)
|
||||
));
|
||||
$switchrole->pix = "i/switchrole";
|
||||
$switchrole->title = get_string('switchroleto');
|
||||
$switchrole->titleidentifier = 'switchroleto,moodle';
|
||||
$returnobject->navitems[] = $switchrole;
|
||||
// Build switch role link.
|
||||
$roles = get_switchable_roles($context);
|
||||
if (is_array($roles) && (count($roles) > 0)) {
|
||||
$switchrole = new stdClass();
|
||||
$switchrole->itemtype = 'link';
|
||||
$switchrole->url = new moodle_url('/course/switchrole.php', array(
|
||||
'id' => $course->id,
|
||||
'switchrole' => -1,
|
||||
'returnurl' => $page->url->out_as_local_url(false)
|
||||
));
|
||||
$switchrole->pix = "i/switchrole";
|
||||
$switchrole->title = get_string('switchroleto');
|
||||
$switchrole->titleidentifier = 'switchroleto,moodle';
|
||||
$returnobject->navitems[] = $switchrole;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnobject;
|
||||
|
Loading…
x
Reference in New Issue
Block a user