$tz = 99;
- while(($tz == '' || $tz == 99 || $tz == NULL) && $next = each($timezones)) {
+ // Loop while $tz is, empty but not zero, or 99, and there is another timezone is the array
+ while(((empty($tz) && !is_numeric($tz)) || $tz == 99) && $next = each($timezones)) {
$tz = $next['value'];
}
-
return is_numeric($tz) ? (float) $tz : $tz;
}
function update_user_login_times() {
global $USER, $DB;
+ $now = time();
+
$user = new stdClass();
+ $user->id = $USER->id;
+
+ // Make sure all users that logged in have some firstaccess.
+ if ($USER->firstaccess == 0) {
+ $USER->firstaccess = $user->firstaccess = $now;
+ }
+
+ // Store the previous current as lastlogin.
$USER->lastlogin = $user->lastlogin = $USER->currentlogin;
- $USER->currentlogin = $user->lastaccess = $user->currentlogin = time();
- $user->id = $USER->id;
+ $USER->currentlogin = $user->currentlogin = $now;
+
+ // Function user_accesstime_log() may not update immediately, better do it here.
+ $USER->lastaccess = $user->lastaccess = $now;
+ $USER->lastip = $user->lastip = getremoteaddr();
$DB->update_record('user', $user);
return true;
$DB->set_field('user', 'auth', $auth, array('username'=>$username));
$user->auth = $auth;
}
- if (empty($user->firstaccess)) { //prevent firstaccess from remaining 0 for manual account that never required confirmation
- $DB->set_field('user','firstaccess', $user->timemodified, array('id' => $user->id));
- $user->firstaccess = $user->timemodified;
- }
update_internal_user_password($user, $password); // just in case salt or encoding were changed (magic quotes too one day)
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteblogassociations', 'blog'), 'error'=>false);
}
- if (!empty($data->reset_course_completion)) {
- // Delete course completion information
+ if (!empty($data->reset_completion)) {
+ // Delete course and activity completion information.
$course = $DB->get_record('course', array('id'=>$data->courseid));
$cc = new completion_info($course);
- $cc->delete_course_completion_data();
- $status[] = array('component'=>$componentstr, 'item'=>get_string('deletecoursecompletiondata', 'completion'), 'error'=>false);
+ $cc->delete_all_completion_data();
+ $status[] = array('component' => $componentstr,
+ 'item' => get_string('deletecompletiondata', 'completion'), 'error' => false);
}
$componentstr = get_string('roles');