mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Changed logic slightly in switchrole_form
This commit is contained in:
parent
0c05b71f58
commit
0cef8a37fa
@ -3729,27 +3729,25 @@ function switchroles_form($courseid) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (has_capability('moodle/role:switchroles', $context)) {
|
||||
if (empty($USER->switchrole)) { // Print a menu
|
||||
if (empty($USER->switchrole)) { // Try to print a menu
|
||||
if (has_capability('moodle/role:switchroles', $context)) {
|
||||
if (!$roles = get_assignable_roles($context)) {
|
||||
return ''; // Nothing to show!
|
||||
}
|
||||
|
||||
return popup_form($CFG->wwwroot.'/course/view.php?id='.$courseid.'&sesskey='.sesskey().'&switchrole=',
|
||||
$roles, 'switchrole', '', get_string('switchroleto'), 'switchrole', '', true);
|
||||
|
||||
} else { // Just a button to return to normal
|
||||
$options = array();
|
||||
$options['id'] = $courseid;
|
||||
$options['sesskey'] = sesskey();
|
||||
$options['switchrole'] = 0;
|
||||
|
||||
return print_single_button($CFG->wwwroot.'/course/view.php', $options,
|
||||
get_string('switchrolereturn'), 'post', '_self', true);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
} else { // Just a button to return to normal
|
||||
$options = array();
|
||||
$options['id'] = $courseid;
|
||||
$options['sesskey'] = sesskey();
|
||||
$options['switchrole'] = 0;
|
||||
|
||||
return '';
|
||||
return print_single_button($CFG->wwwroot.'/course/view.php', $options,
|
||||
get_string('switchrolereturn'), 'post', '_self', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user