From 3e21903846f0f03c0f9f247a1d9975f8fda31c4e Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 28 Sep 2006 06:04:39 +0000 Subject: [PATCH] Cleaning up user index a bit --- lang/en_utf8/role.php | 1 + theme/standard/styles_layout.css | 3 + user/index.php | 122 ++++++++++++++----------------- 3 files changed, 58 insertions(+), 68 deletions(-) diff --git a/lang/en_utf8/role.php b/lang/en_utf8/role.php index 40a5ba056f..f0530f956a 100644 --- a/lang/en_utf8/role.php +++ b/lang/en_utf8/role.php @@ -37,6 +37,7 @@ $string['roletooverride'] = 'Role to override'; $string['roles'] = 'Roles'; $string['selectrole'] = 'Select a role'; $string['viewrole'] = 'View role details'; +$string['xuserswiththerole'] = 'Users with the role \"$a->role\": $a->number'; $string['site:doanything'] = 'Allowed to do everything'; $string['legacy:guest'] = 'LEGACY ROLE: Guest'; diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 7879a1da86..e4d3e66b8d 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -1551,6 +1551,9 @@ body#course-participation #showall { text-align:center; margin: 10px 0px; } +body#user-index .rolesform { + text-align:center; +} /*** *** Modules: Assignment diff --git a/user/index.php b/user/index.php index 3a74657d95..3e558e3cc5 100644 --- a/user/index.php +++ b/user/index.php @@ -156,27 +156,6 @@ } -/// If there are multiple Roles in the course, then show a drop down menu for switching - - $rolenames = array(); - - if ($roles = get_roles_used_in_context($context)) { - - foreach ($roles as $role) { - $rolenames[$role->id] = $role->name; - } - - if (!empty($roleid)) { - echo '
'; - echo '
'; - echo ''.get_string('currentrole', 'role').': '; - choose_from_menu($rolenames, 'roleid', $roleid, '', $script='rolesform.submit()'); - echo '
'; - } - } - - - /// Print settings and things in a table across the top echo ''; @@ -277,43 +256,12 @@ } } - - $exceptions = array(); // This will be an array of userids that are shown as teachers and thus - // do not have to be shown as users as well. Only relevant on site course. - - if ($isteacher) { - echo ' - -'; - echo ''; - echo ''; - echo ''; - } - /// Define a table showing a list of users in the current role. @@ -401,13 +349,6 @@ function checkchecked(form) { $where .= ' AND gm.groupid = '.$currentgroup; } - if ($course->id == SITEID) { - $guest = get_guest(); - $exceptions[] = $guest->id; - - $where .= ' AND u.id NOT IN ('.implode(',', $exceptions).')'; - } - $totalcount = count_records_sql('SELECT COUNT(distinct u.id) '.$from.$where); // 1 person can have multiple assignments if ($table->get_sql_where()) { @@ -427,18 +368,63 @@ function checkchecked(form) { $students = get_records_sql($select.$from.$where.$wheresearch.$sort, $table->get_page_start(), $table->get_page_size()); + + /// If there are multiple Roles in the course, then show a drop down menu for switching + + if ($rolenames) { + echo '
'; + echo get_string('currentrole', 'role').': '; + $rolenames = array(0 => get_string('all')) + $rolenames; + popup_form('index.php?contextid='.$contextid.'&roleid=', $rolenames, 'rolesform', $roleid, ''); + echo '
'; + } + + if (!$currentrole = get_record('role','id',$roleid)) { error('That role does not exist'); } - $a->number = $totalcount; $a->role = $currentrole->name; - echo '

'.get_string('xuserswiththerole', 'role', $a); + $heading = get_string('xuserswiththerole', 'role', $a); if (user_can_assign($context, $roleid)) { - echo ' '; - echo ''; + $heading .= ' '; + $heading .= ''; + } + print_heading($heading, 'center', 3); + + + if ($isteacher) { + echo ' + +'; + echo ''; + echo ''; + echo ''; } - echo '

'; if ($CFG->longtimenosee > 0 && $CFG->longtimenosee < 1000 && $totalcount > 0) { echo '

('.get_string('unusedaccounts', '', $CFG->longtimenosee).')

'; -- 2.39.5