* @param string $sort a SQL snippet for the sorting criteria to use
*/
function get_users($get=true, $search="", $confirmed=false, $exceptions="", $sort="firstname ASC",
- $firstinitial="", $lastinitial="") {
+ $firstinitial="", $lastinitial="", $page=0, $recordsperpage=99999) {
global $CFG;
switch ($CFG->dbtype) {
case "mysql":
+ $limit = "LIMIT $page,$recordsperpage";
$fullname = " CONCAT(firstname,\" \",lastname) ";
$LIKE = "LIKE";
break;
case "postgres7":
+ $limit = "LIMIT $recordsperpage OFFSET ".($page);
$fullname = " firstname||' '||lastname ";
$LIKE = "ILIKE";
break;
default:
+ $limit = "LIMIT $recordsperpage,$page";
$fullname = " firstname||\" \"||lastname ";
$LIKE = "ILIKE";
}
}
if ($get) {
- return get_records_select("user", "$select $sort");
+ return get_records_select("user", "$select $sort $limit");
} else {
- return count_records_select("user", "$select $sort");
+ return count_records_select("user", "$select $sort $limit");
}
}
}
}
+ if ($oldversion < 2004053000) { /// set defaults for site course
+ $site = get_site();
+ set_field('course', 'groupmodeforce', 1, 'id', $site->id);
+ set_field('course', 'teacher', get_string('administrator'), 'id', $site->id);
+ set_field('course', 'teachers', get_string('administrators'), 'id', $site->id);
+ set_field('course', 'student', get_string('user'), 'id', $site->id);
+ set_field('course', 'students', get_string('users'), 'id', $site->id);
+ }
+
return $result;
}
}
}
+ if ($oldversion < 2004053000) { /// set defaults for site course
+ $site = get_site();
+ set_field('course', 'groupmodeforce', 1, 'id', $site->id);
+ set_field('course', 'teacher', get_string('administrator'), 'id', $site->id);
+ set_field('course', 'teachers', get_string('administrators'), 'id', $site->id);
+ set_field('course', 'student', get_string('user'), 'id', $site->id);
+ set_field('course', 'students', get_string('users'), 'id', $site->id);
+ }
+
return $result;
}
"$participantslink", "", "", true, " ", navmenu($course));
}
+ $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 "<h2 align=\"center\">$course->teachers</h2>";
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,";
}
}
}
}
-
- if ($sort == "lastaccess") {
- $dsort = "s.timeaccess";
+ $guest = get_guest();
+ $exceptions .= $guest->id;
+
+ $site = get_site();
+ if ($course->id == $site->id) { // 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 {
- $dsort = "u.$sort";
- }
-
- $students = get_course_students($course->id, $dsort, $dir, $page*$perpage,
+ 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;
+ $totalcount = count_course_students($course, "", "", "", $currentgroup);
+ if ($firstinitial or $lastinitial) {
+ $matchcount = count_course_students($course, "", $firstinitial, $lastinitial, $currentgroup);
+ } else {
+ $matchcount = $totalcount;
+ }
}
-
echo "<h2 align=center>$totalcount $course->students</h2>";
if (($CFG->longtimenosee < 500) and (!$page) and ($sort == "lastaccess")) {
}
- if ($matchcount == 0) {
+ if ($matchcount < 1) {
print_heading(get_string("nostudentsfound", "", $course->students));
} if (0 < $matchcount and $matchcount < USER_SMALL_CLASS) { // Print simple listing