Improvements to logs when looking at site logs.
Also, improvements to get_site_users (slower but it works now!)
This commit is contained in:
+13
-11
@@ -27,15 +27,19 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
|
||||
$users = array();
|
||||
|
||||
if ($course->category) {
|
||||
if ($courseusers = get_course_users($course->id, "u.lastaccess DESC")) {
|
||||
foreach ($courseusers as $courseuser) {
|
||||
$users[$courseuser->id] = "$courseuser->firstname $courseuser->lastname";
|
||||
}
|
||||
}
|
||||
if ($guest = get_guest()) {
|
||||
$users[$guest->id] = "$guest->firstname $guest->lastname";
|
||||
$courseusers = get_course_users($course->id, "u.lastaccess DESC");
|
||||
} else {
|
||||
$courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname");
|
||||
}
|
||||
|
||||
if ($courseusers) {
|
||||
foreach ($courseusers as $courseuser) {
|
||||
$users[$courseuser->id] = "$courseuser->firstname $courseuser->lastname";
|
||||
}
|
||||
}
|
||||
if ($guest = get_guest()) {
|
||||
$users[$guest->id] = "$guest->firstname $guest->lastname";
|
||||
}
|
||||
|
||||
if (isadmin()) {
|
||||
if ($ccc = get_records("course", "", "", "fullname")) {
|
||||
@@ -92,9 +96,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
|
||||
} else {
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">";
|
||||
}
|
||||
if ($course->category) {
|
||||
choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") );
|
||||
}
|
||||
choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") );
|
||||
choose_from_menu ($dates, "date", $selecteddate, get_string("alldays"));
|
||||
echo "<INPUT TYPE=submit VALUE=\"".get_string("showtheselogs")."\">";
|
||||
echo "</FORM>";
|
||||
@@ -129,7 +131,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
|
||||
|
||||
} else {
|
||||
$selector = "l.userid = u.id"; // Show all courses
|
||||
if ($ccc = get_courses(-1)) {
|
||||
if ($ccc = get_courses("all", "c.id ASC", "c.id,c.shortname")) {
|
||||
foreach ($ccc as $cc) {
|
||||
$courses[$cc->id] = "$cc->shortname";
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can look at the site logs");
|
||||
}
|
||||
$user = "";
|
||||
}
|
||||
|
||||
$strlogs = get_string("logs");
|
||||
|
||||
+24
-15
@@ -970,27 +970,36 @@ function get_course_users($courseid, $sort="u.lastaccess DESC") {
|
||||
/// ORDER BY $sort");
|
||||
}
|
||||
|
||||
function get_site_users($sort="u.lastaccess DESC") {
|
||||
function get_site_users($sort="u.lastaccess DESC", $select="") {
|
||||
/// Returns a list of all active users who are enrolled
|
||||
/// or teaching in courses on this server
|
||||
|
||||
global $CFG, $db;
|
||||
|
||||
//$db->debug = true;
|
||||
|
||||
return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat,
|
||||
u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_students s,
|
||||
{$CFG->prefix}user_teachers t,
|
||||
{$CFG->prefix}user_coursecreators c,
|
||||
{$CFG->prefix}user_admins a
|
||||
WHERE s.userid = u.id
|
||||
OR t.userid = u.id
|
||||
OR a.userid = u.id
|
||||
OR c.userid = u.id
|
||||
GROUP BY u.id
|
||||
ORDER BY $sort ");
|
||||
if ($select) {
|
||||
$selectinfo = $select;
|
||||
} else {
|
||||
$selectinfo = "u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat,".
|
||||
"u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture";
|
||||
}
|
||||
|
||||
|
||||
if (!$students = get_records_sql("SELECT $selectinfo from {$CFG->prefix}user u, {$CFG->prefix}user_students s
|
||||
WHERE s.userid = u.id GROUP BY u.id ORDER BY $sort")) {
|
||||
$students = array();
|
||||
}
|
||||
if (!$teachers = get_records_sql("SELECT $selectinfo from {$CFG->prefix}user u, {$CFG->prefix}user_teachers t
|
||||
WHERE t.userid = u.id GROUP BY u.id ORDER BY $sort")) {
|
||||
$teachers = array();
|
||||
}
|
||||
if (!$admins = get_records_sql("SELECT $selectinfo from {$CFG->prefix}user u, {$CFG->prefix}user_admins a
|
||||
WHERE a.userid = u.id GROUP BY u.id ORDER BY $sort")) {
|
||||
$admins = array();
|
||||
}
|
||||
$users = array_merge($teachers, $students);
|
||||
$users = array_merge($users, $admins);
|
||||
return $users;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user