diff --git a/user/index.php b/user/index.php index 9aeb8811dd4..793b3c1d048 100644 --- a/user/index.php +++ b/user/index.php @@ -157,21 +157,26 @@ } - /***************************************** - * drop down for swapping between roles * - *****************************************/ +/// If there are multiple Roles in the course, then show a drop down menu for switching - if (!$roleid) { - if ($options) { - $roleid = array_shift(array_keys($options)); // get first element + if ($roles = get_roles_used_in_context($context)) { + + $rolenames = array(); + + foreach ($roles as $role) { + $rolenames[$role->id] = $role->name; } - } - echo '
'; + if (empty($roleid)) { + $roleid = array_shift(array_keys($rolenames)); // get first element + } + + echo ''; + } @@ -179,7 +184,7 @@ echo '| '; print_string('mycourses'); echo ': '; @@ -187,7 +192,6 @@ foreach ($mycourses as $mycourse) { $my_course[$mycourse->id] = $mycourse->shortname; } - //choose_from_menu($my_course, 'id', $course->id, '', 'courseform.submit()'); popup_form($CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&roleid='.$roleid.'&id=',$my_course,'courseform',$course->id); echo ' |