From 1263a0ff1dc28322838e38e9ba807a4f61da376b Mon Sep 17 00:00:00 2001 From: stronk7 Date: Wed, 11 Mar 2009 11:22:55 +0000 Subject: [PATCH] MDL-18518 user firstaccess - added suport to display user->firstaccess. Credit goes to Anthony Borrow! Merged from 19_STABLE --- admin/settings/users.php | 1 + lang/en_utf8/moodle.php | 1 + lib/moodlelib.php | 4 ++++ user/view.php | 9 ++++++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/admin/settings/users.php b/admin/settings/users.php index d0f00ecc1c..102f38557b 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -161,6 +161,7 @@ if ($hassiteconfig 'yahooid' => get_string('yahooid'), 'aimid' => get_string('aimid'), 'msnid' => get_string('msnid'), + 'firstaccess' => get_string('firstaccess'), 'lastaccess' => get_string('lastaccess'), 'mycourses' => get_string('mycourses')))); diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index d6ef84212c..154f97f6db 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -672,6 +672,7 @@ $string['filesfolders'] = 'Files/folders'; $string['filloutallfields'] = 'Please fill out all fields in this form'; $string['filter'] = 'Filter'; $string['findmorecourses'] = 'Find more courses...'; +$string['firstaccess'] = 'First access'; $string['firstdayofweek'] = '0'; $string['firstname'] = 'First name'; $string['firsttime'] = 'Is this your first time here?'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 866f1952ad..75ff6179b8 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3099,6 +3099,10 @@ function authenticate_user_login($username, $password) { $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) diff --git a/user/view.php b/user/view.php index e8983df682..8cb7078383 100644 --- a/user/view.php +++ b/user/view.php @@ -351,7 +351,14 @@ print_row(get_string('courses').':', rtrim($courselisting,', ')); } } - + if (!isset($hiddenfields['firstaccess'])) { + if ($user->firstaccess) { + $datestring = userdate($user->firstaccess)."  (".format_time(time() - $user->firstaccess).")"; + } else { + $datestring = get_string("never"); + } + print_row(get_string("firstaccess").":", $datestring); + } if (!isset($hiddenfields['lastaccess'])) { if ($user->lastaccess) { $datestring = userdate($user->lastaccess)."  (".format_time(time() - $user->lastaccess).")"; -- 2.39.5