}
// Fetch user data for given user id
-function fetchUserData ($userid, $column = 'userid') {
+function fetchUserData ($value, $column = 'userid') {
// If we should look for userid secure&set it here
if (substr($column, -2, 2) == 'id') {
// Secure userid
- $userid = bigintval($userid);
+ $value = bigintval($value);
// Set it here
- setCurrentUserId($userid);
+ setCurrentUserId($value);
// Don't look for invalid userids...
- if (!isValidUserId($userid)) {
+ if (!isValidUserId($value)) {
// Invalid, so abort here
- debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $userid . ' is invalid.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $value . ' is invalid.');
} elseif (isUserDataValid()) {
// Use cache, so it is fine
return true;
// Extra statements
$ADD = '';
- if (isExtensionInstalledAndNewer('user', '0.3.5')) $ADD = ', UNIX_TIMESTAMP(`lock_timestamp`) AS `lock_timestamp`';
+ if (isExtensionInstalledAndNewer('user', '0.3.5')) {
+ $ADD = ', UNIX_TIMESTAMP(`lock_timestamp`) AS `lock_timestamp`';
+ } // END - if
// Query for the user
$result = SQL_QUERY_ESC("SELECT *".$ADD." FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1",
- array($column, $userid), __FUNCTION__, __LINE__);
+ array($column, $value), __FUNCTION__, __LINE__);
// Do we have a record?
if (SQL_NUMROWS($result) == 1) {
// Set the userid for later use
setCurrentUserId($data['userid']);
+
+ // And cache the data for this userid
$GLOBALS['user_data'][getCurrentUserId()] = $data;
// Rewrite 'last_failure' if found and ext-user has version >= 0.3.7