Skip to content

Commit

Permalink
MDL-14034 List of participants in SITE course failing... - fixed last…
Browse files Browse the repository at this point in the history
… access - credit goes to Eloy; merged from MOODLE_19_STABLE
  • Loading branch information
skodak committed Apr 2, 2008
1 parent 5bb5ee5 commit 0749cae
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions user/index.php
Expand Up @@ -199,9 +199,20 @@
echo '</td>';

// get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
// this might not work anymore because you always going to get yourself as the most recent entry? added $USER!=$user ch
$minlastaccess = get_field_sql('SELECT min(timeaccess) FROM '.$CFG->prefix.'user_lastaccess WHERE courseid = '.$course->id.' AND timeaccess != 0 AND userid!='.$USER->id);
$lastaccess0exists = record_exists('user_lastaccess','courseid',$course->id,'timeaccess',0);
// we need to make it diferently for normal courses and site course
if ($context->id != $frontpagectx->id) {
$minlastaccess = get_field_sql('SELECT min(timeaccess)
FROM '.$CFG->prefix.'user_lastaccess
WHERE courseid = '.$course->id.'
AND timeaccess != 0');
$lastaccess0exists = record_exists('user_lastaccess', 'courseid', $course->id, 'timeaccess', 0);
} else {
$minlastaccess = get_field_sql('SELECT min(lastaccess)
FROM '.$CFG->prefix.'user
WHERE lastaccess != 0');
$lastaccess0exists = record_exists('user','lastaccess',0);
}

$now = usergetmidnight(time());
$timeaccess = array();

Expand Down Expand Up @@ -421,11 +432,11 @@
AND u.username != 'guest'
$adminroles
$hiddensql ";
$where .= get_lastaccess_sql($accesssince);
$where .= get_course_lastaccess_sql($accesssince);
} else {
$where = "WHERE u.deleted = 0
AND u.username != 'guest'";
$where .= get_lastaccess_sql($accesssince);
$where .= get_user_lastaccess_sql($accesssince);
}
$wheresearch = '';

Expand Down Expand Up @@ -823,14 +834,25 @@ function checkchecked(form) {
}


function get_lastaccess_sql($accesssince='') {
function get_course_lastaccess_sql($accesssince='') {
if (empty($accesssince)) {
return '';
}
if ($accesssince == -1) { // never
return ' AND ul.timeaccess = 0';
} else {
return ' AND ul.timeaccess != 0 AND timeaccess < '.$accesssince;
return ' AND ul.timeaccess != 0 AND ul.timeaccess < '.$accesssince;
}
}

function get_user_lastaccess_sql($accesssince='') {
if (empty($accesssince)) {
return '';
}
if ($accesssince == -1) { // never
return ' AND u.lastaccess = 0';
} else {
return ' AND u.lastaccess != 0 AND u.lastaccess < '.$accesssince;
}
}

Expand Down

0 comments on commit 0749cae

Please sign in to comment.