id); if (!$course->category) { if (!$CFG->showsiteparticipantslist and !isteacher(SITEID)) { notice(get_string('sitepartlist0')); } if ($CFG->showsiteparticipantslist < 2 and !isteacherinanycourse()) { notice(get_string('sitepartlist1')); } } add_to_log($course->id, "user", "view all", "index.php?id=$course->id", ""); $isteacher = isteacher($course->id); $showteachers = ($page == 0 and $sort == "lastaccess" and $dir == "desc"); if ($showteachers) { $participantslink = get_string("participants"); } else { $participantslink = "id\">".get_string("participants").""; } $isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and !isteacheredit($course->id)); $currentgroup = $isseparategroups ? get_current_group($course->id) : NULL; if ($course->category) { print_header("$course->shortname: ".get_string("participants"), "$course->fullname", "id\">$course->shortname -> ". "$participantslink", "", "", true, " ", navmenu($course)); } else { 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"; if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) { echo ' '; echo ''; } echo '

'; if ($compactmode) { // First of all, remove teachers with no authority $teachers = array_filter($teachers, create_function('$t','return ($t->authority > 0);')); // And now show the remainder as usual $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) and ($teacher->authority > 0)) { 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 if ($firstinitial or $lastinitial) { $matchcount = get_users(false, '', true, '', '', $firstinitial, $lastinitial) - 1; } else { $matchcount = $totalcount; } } else { if ($sort == "lastaccess") { $dsort = "s.timeaccess"; } else { $dsort = "u.$sort"; } $students = get_course_students($course->id, $dsort, $dir, $page*$perpage, $perpage, $firstinitial, $lastinitial, $currentgroup); $totalcount = count_course_students($course, "", "", "", $currentgroup); if ($firstinitial or $lastinitial) { $matchcount = count_course_students($course, "", $firstinitial, $lastinitial, $currentgroup); } else { $matchcount = $totalcount; } } $a->count = $totalcount; $a->items = $course->students; echo '

'.get_string('counteditems', '', $a); if (isteacheredit($course->id)) { echo ' '; echo ''; } echo '

'; if (($CFG->longtimenosee > 0) and ($CFG->longtimenosee < 1000) and (!$page) and ($sort == "lastaccess")) { echo '

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

'; } /// Print paging bars if necessary if ($totalcount > $perpage) { $alphabet = explode(',', get_string('alphabet')); $strall = get_string("all"); /// Bar of first initials echo "

"; echo get_string("firstname")." : "; if ($firstinitial) { echo " id&sort=firstname&dir=ASC&". "perpage=$perpage&lastinitial=$lastinitial\">$strall "; } else { echo " $strall "; } foreach ($alphabet as $letter) { if ($letter == $firstinitial) { echo " $letter "; } else { echo " id&sort=firstname&dir=ASC&". "perpage=$perpage&lastinitial=$lastinitial&firstinitial=$letter\">$letter "; } } echo "
"; /// Bar of last initials echo get_string("lastname")." : "; if ($lastinitial) { echo " id&sort=lastname&dir=ASC&". "perpage=$perpage&firstinitial=$firstinitial\">$strall "; } else { echo " $strall "; } foreach ($alphabet as $letter) { if ($letter == $lastinitial) { echo " $letter "; } else { echo " id&sort=lastname&dir=ASC&". "perpage=$perpage&firstinitial=$firstinitial&lastinitial=$letter\">$letter "; } } echo "

"; echo "
"; print_paging_bar($matchcount, $page, $perpage, "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&"); } if ($matchcount < 1) { print_heading(get_string("nostudentsfound", "", $course->students)); } 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 $format, $sort, $course, $dir, $CFG; $columns = array("firstname", "lastname", "city", "country", "lastaccess"); $countries = get_list_of_countries(); $strnever = get_string("never"); $datestring->day = get_string("day"); $datestring->days = get_string("days"); $datestring->hour = get_string("hour"); $datestring->hours = get_string("hours"); $datestring->min = get_string("min"); $datestring->mins = get_string("mins"); $datestring->sec = get_string("sec"); $datestring->secs = get_string("secs"); foreach ($columns as $column) { $colname[$column] = get_string($column); if ($sort != $column) { $columnicon = ""; if ($column == "lastaccess") { $columndir = "desc"; } else { $columndir = "asc"; } } else { $columndir = $dir == "asc" ? "desc":"asc"; if ($column == "lastaccess") { $columnicon = $dir == "asc" ? "up":"down"; } else { $columnicon = $dir == "asc" ? "down":"up"; } $columnicon = " pixpath/t/$columnicon.gif\" alt=\"\"/>"; } $$column = "id&sort=$column&dir=$columndir&format=$format\">".$colname["$column"]."$columnicon"; } 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 ($users as $user) { $sstudents[$user->id] = $user->country; } asort($sstudents); foreach ($sstudents as $key => $value) { $nstudents[] = $users[$key]; } $users = $nstudents; } $table->head = array (" ", "$firstname / $lastname", $city, $country, $lastaccess); $table->align = array ("left", "left", "left", "left", "left"); $table->size = array ("10", "*", "*", "*", "*"); $table->size = array ("10", "*", "*", "*", "*"); $table->cellpadding = 4; $table->cellspacing = 0; foreach ($users as $user) { if ($user->lastaccess) { $lastaccess = format_time(time() - $user->lastaccess, $datestring); } else { $lastaccess = $strnever; } $picture = print_user_picture($user->id, $course->id, $user->picture, false, true); $fullname = fullname($user, $isteacher); $table->data[] = array ($picture, "wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname", $user->city, $user->country, $lastaccess); } print_table($table); } ?>