From 4bc162b7a5394d7db7af1bc6c348ba0aadf243ae Mon Sep 17 00:00:00 2001 From: defacer Date: Wed, 1 Sep 2004 13:56:12 +0000 Subject: [PATCH] Lots of things going on: 1. Added a dropdown box at the top right which allows you to manually choose the display mode for the user lists. 2. Fixed the bug where "Show all X users" was displayed when it shouldn't. 3. Merged the latest changes from the MOODLE_14_STABLE branch. This wasn't done before and it gave me the creeps. All changes seem to be good, so I hope I didn't checkin anything dangerous. Will synchronize the MERGED tag on the branch, too. --- user/index.php | 109 +++++++++++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 39 deletions(-) diff --git a/user/index.php b/user/index.php index 7f7d2ebd9c..dec2266489 100644 --- a/user/index.php +++ b/user/index.php @@ -14,7 +14,9 @@ optional_variable($lastinitial, ""); // only show students with this last initial optional_variable($firstinitial, ""); // only show students with this first initial optional_variable($perpage, "20"); // how many per page + optional_variable($_GET['format'], 'brief'); // what kind of view + $compactmode = ($_GET['format'] == 'brief'); if (! $course = get_record("course", "id", $id)) { error("Course ID is incorrect"); @@ -22,6 +24,15 @@ require_login($course->id); + if (!$course->category) { + if (!$CFG->showsiteparticipantslist and !isteacher(SITEID)) { + notice(get_string('sitepartlist0')); + } + if ($CFG->showsiteparticipantslist < 2 and !isteacher()) { + notice(get_string('sitepartlist1')); + } + } + add_to_log($course->id, "user", "view all", "index.php?id=$course->id", ""); $isteacher = isteacher($course->id); @@ -33,7 +44,7 @@ $participantslink = "id\">".get_string("participants").""; } - $isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and + $isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and !isteacheredit($course->id)); $currentgroup = $isseparategroups ? get_current_group($course->id) : NULL; @@ -43,31 +54,47 @@ "id>$course->shortname -> ". "$participantslink", "", "", true, " ", navmenu($course)); } else { - print_header("$course->shortname: ".get_string("participants"), "$course->fullname", + print_header("$course->shortname: ".get_string("participants"), "$course->fullname", "$participantslink", "", "", true, " ", navmenu($course)); } + echo '
'; + echo get_string('userlist').': '; + $formatmenu = array( + '' => get_string('detailedmore'), + 'brief' => get_string('detailedless'), + ); + // [pj] Oh, the things I do to put it in one line... :P + echo str_replace(''; + $exceptions = ''; // This will be a list 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 ($showteachers) { if ($teachers = get_course_teachers($course->id)) { echo "

$course->teachers

"; - foreach ($teachers as $teacher) { - if ($isseparategroups) { - if ($teacher->editall or ismember($currentgroup, $teacher->id)) { + if($compactmode) { + $exceptions .= implode(',', array_keys($teachers)); + print_user_table($teachers, $isteacher); + } + else { + foreach ($teachers as $teacher) { + if ($isseparategroups) { + if ($teacher->editall or ismember($currentgroup, $teacher->id)) { + print_user($teacher, $course); + $exceptions .= "$teacher->id,"; + } + } else if ($teacher->authority > 0) { // Don't print teachers with no authority print_user($teacher, $course); $exceptions .= "$teacher->id,"; } - } else if ($teacher->authority > 0) { // Don't print teachers with no authority - print_user($teacher, $course); - $exceptions .= "$teacher->id,"; } } } } $guest = get_guest(); $exceptions .= $guest->id; - + if ($course->id == SITEID) { // Show all site users (even unconfirmed) $students = get_users(true, '', true, $exceptions, $sort.' '.$dir, $firstinitial, $lastinitial, $page*$perpage, $perpage); $totalcount = get_users(false, '', true, '', '', '', '') - 1; // -1 to not count guest user @@ -82,7 +109,7 @@ } else { $dsort = "u.$sort"; } - $students = get_course_students($course->id, $dsort, $dir, $page*$perpage, + $students = get_course_students($course->id, $dsort, $dir, $page*$perpage, $perpage, $firstinitial, $lastinitial, $currentgroup); $totalcount = count_course_students($course, "", "", "", $currentgroup); if ($firstinitial or $lastinitial) { @@ -147,7 +174,7 @@ echo "

"; echo ""; - print_paging_bar($matchcount, $page, $perpage, + print_paging_bar($matchcount, $page, $perpage, "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&"); } @@ -155,14 +182,29 @@ if ($matchcount < 1) { print_heading(get_string("nostudentsfound", "", $course->students)); - } if (0 < $matchcount and $matchcount < USER_SMALL_CLASS) { // Print simple listing + } if (!$compactmode && (0 < $matchcount and $matchcount < USER_SMALL_CLASS)) { // Print simple listing foreach ($students as $student) { print_user($student, $course); } } else if ($matchcount > 0) { + print_user_table($students, $isteacher); + print_paging_bar($matchcount, $page, $perpage, + "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&"); + + if ($perpage < $totalcount) { + echo "

"; + echo "id&sort=$sort&dir=$dir&perpage=99999\">".get_string("showall", "", $totalcount).""; + echo "

"; + } + } + print_footer($course); + +function print_user_table($users, $isteacher) { // Print one big table with abbreviated info + global $sort, $course, $dir, $CFG; + $columns = array("firstname", "lastname", "city", "country", "lastaccess"); $countries = get_list_of_countries(); @@ -199,18 +241,18 @@ $$column = "id&sort=$column&dir=$columndir\">".$colname["$column"]."$columnicon"; } - foreach ($students as $key => $student) { - $students[$key]->country = ($student->country) ? $countries[$student->country] : ''; + foreach ($users as $key => $user) { + $users[$key]->country = ($user->country) ? $countries[$user->country] : ''; } if ($sort == "country") { // Need to re-sort by full country name, not code - foreach ($students as $student) { - $sstudents[$student->id] = $student->country; + foreach ($users as $user) { + $sstudents[$user->id] = $user->country; } asort($sstudents); foreach ($sstudents as $key => $value) { - $nstudents[] = $students[$key]; + $nstudents[] = $users[$key]; } - $students = $nstudents; + $users = $nstudents; } @@ -220,37 +262,26 @@ $table->size = array ("10", "*", "*", "*", "*"); $table->cellpadding = 4; $table->cellspacing = 0; - - foreach ($students as $student) { - if ($student->lastaccess) { - $lastaccess = format_time(time() - $student->lastaccess, $datestring); + foreach ($users as $user) { + + if ($user->lastaccess) { + $lastaccess = format_time(time() - $user->lastaccess, $datestring); } else { $lastaccess = $strnever; } - $picture = print_user_picture($student->id, $course->id, $student->picture, false, true); + $picture = print_user_picture($user->id, $course->id, $user->picture, false, true); - $fullname = fullname($student, $isteacher); + $fullname = fullname($user, $isteacher); $table->data[] = array ($picture, - "wwwroot/user/view.php?id=$student->id&course=$course->id\">$fullname", - "$student->city", - "$student->country", + "wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname", + "$user->city", + "$user->country", "$lastaccess"); } print_table($table); - - print_paging_bar($matchcount, $page, $perpage, - "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&"); - - if ($perpage != 99999) { - echo "

"; - echo "id&sort=$sort&dir=$dir&perpage=99999\">".get_string("showall", "", $totalcount).""; - echo "

"; - } - } - - print_footer($course); +} ?> -- 2.39.5