- $ret = $GLOBALS['cache_array']['nicknames'][$userid];
-
- // Increment cache counter
- incrementConfigEntry('cache_hits');
- } elseif (NICKNAME_IS_ACTIVE($userid)) {
- // Search for non-empty nickname
- $result = SQL_QUERY_ESC("SELECT nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND nickname != '' LIMIT 1",
- array(bigintval($userid)), __FUNCTION__, __LINE__);
-
- // Found?
- if (SQL_NUMROWS($result) == 1) {
- // Load nickname from database
- list($ret) = SQL_FETCHROW($result);
+ $ret = $GLOBALS['nicknames'][$userid];
+ } else {
+ // Init result
+ $result = FALSE;
+
+ // Nickname or userid used?
+ if ('' . bigintval($userid, TRUE, FALSE) . '' === '' . $userid . '') {
+ // Userid given, so try to load user data
+ if (fetchUserData($userid)) {
+ // Load nickname from database
+ $ret = getUserData('nickname');
+
+ // Put it in cche
+ $GLOBALS['nicknames'][$userid] = $ret;
+ } // END - if
+ } else {
+ // Direct nickname found
+ $ret = $userid;