// Get username
function getUsername () {
- // default is guest
- $username = getMessage('USERNAME_GUEST');
-
// User name set?
- if (isset($GLOBALS['username'])) {
- // Use the set name
- $username = $GLOBALS['username'];
+ if (!isset($GLOBALS['username'])) {
+ // No, so it has to be a guest
+ $GLOBALS['username'] = getMessage('USERNAME_GUEST');
} // END - if
// Return it
- return $username;
+ return $GLOBALS['username'];
}
// Wrapper function for installation phase
// User id should not be zero so abort here
if (!isCurrentUserIdSet()) return false;
- // Is the array there and filled?
- return ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
+ // Is it cached?
+ if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
+ // Determine it
+ $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
+ } // END - if
+
+ // Return the result
+ return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
}
// Setter for current userid
// Wrapper for fetchUserData() and getUserData() calls
function getFetchedUserData ($keyColumn, $userId, $valueColumn) {
- // Default is 'guest'
- $data = getMessage('USERNAME_GUEST');
-
- // Can we fetch the user data?
- if (($userId > 0) && (fetchUserData($userId, $keyColumn))) {
- // Now get the data back
- $data = getUserData($valueColumn);
+ // Is it cached?
+ if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) {
+ // Default is 'guest'
+ $data = getMessage('USERNAME_GUEST');
+
+ // Can we fetch the user data?
+ if (($userId > 0) && (fetchUserData($userId, $keyColumn))) {
+ // Now get the data back
+ $data = getUserData($valueColumn);
+ } // END - if
+
+ // Cache it
+ $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data;
} // END - if
// Return it
- return $data;
+ return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn];
}
// Wrapper for strpos() to ease porting from deprecated ereg() function