From 0cef8a37fa81910cbed802283d0403cbe5d73a0f Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 21 Sep 2006 14:04:32 +0000 Subject: [PATCH] Changed logic slightly in switchrole_form --- lib/weblib.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index f918adca3da..313a5671892 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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); + } }