mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Tidying add_to_log slghtly
This commit is contained in:
parent
8ca1053a45
commit
cb80265b21
1 changed files with 13 additions and 10 deletions
|
@ -1219,7 +1219,7 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$userid = $user;
|
$userid = $user;
|
||||||
} else {
|
} else {
|
||||||
if (isset($USER->realuser)) { // Don't log
|
if (!empty($USER->realuser)) { // Don't log
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userid = empty($USER->id) ? '0' : $USER->id;
|
$userid = empty($USER->id) ? '0' : $USER->id;
|
||||||
|
@ -1241,22 +1241,25 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
|
||||||
if (!$result and ($CFG->debug > 7)) {
|
if (!$result and ($CFG->debug > 7)) {
|
||||||
echo '<p>Error: Could not insert a new entry to the Moodle log</p>'; // Don't throw an error
|
echo '<p>Error: Could not insert a new entry to the Moodle log</p>'; // Don't throw an error
|
||||||
}
|
}
|
||||||
if ( isset($USER) && (empty($user) || $user==$USER->id) ) {
|
|
||||||
$db->Execute('UPDATE '. $CFG->prefix .'user SET lastip=\''. $REMOTE_ADDR .'\', lastaccess=\''. $timenow .'\'
|
/// Store lastaccess times for the current user
|
||||||
|
|
||||||
|
if (!empty($USER->id) && ($userid == $USER->id) ) {
|
||||||
|
$db->Execute('UPDATE '. $CFG->prefix .'user
|
||||||
|
SET lastip=\''. $REMOTE_ADDR .'\', lastaccess=\''. $timenow .'\'
|
||||||
WHERE id = \''. $userid .'\' ');
|
WHERE id = \''. $userid .'\' ');
|
||||||
if ($courseid != SITEID && !empty($courseid)) { // logins etc dont't have a courseid and isteacher will break without it.
|
if ($courseid != SITEID && !empty($courseid)) {
|
||||||
if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++;};
|
if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++;};
|
||||||
|
|
||||||
/// since we are quering the log table for lastaccess time now, can stop doing this? tables are gone
|
if ($record = get_record('user_lastaccess', 'userid', $userid, 'courseid', $courseid)) {
|
||||||
if (!$record = get_record('user_lastaccess', 'userid', $userid, 'courseid', $courseid)) {
|
$record->timeaccess = $timenow;
|
||||||
|
return update_record('user_lastaccess', $record);
|
||||||
|
} else {
|
||||||
$record = new object;
|
$record = new object;
|
||||||
$record->userid = $userid;
|
$record->userid = $userid;
|
||||||
$record->courseid = $courseid;
|
$record->courseid = $courseid;
|
||||||
$record->timeaccess = $timenow;
|
$record->timeaccess = $timenow;
|
||||||
return insert_record('user_lastaccess', $record);
|
return insert_record('user_lastaccess', $record);
|
||||||
} else {
|
|
||||||
$record->timeaccess = $timenow;
|
|
||||||
return update_record('user_lastaccess', $record);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue