New function fetchUserData() introduced to API, total rewrite (not all)
[mailer.git] / inc / wrapper-functions.php
index b76f513d39a06a91a60111ec4535c8be4051ab0b..2ad98e13dab1434b5319428a77be691e02c36272 100644 (file)
@@ -443,15 +443,15 @@ function isNicknameUsed ($userid) {
        $isUsed = false;
 
        // Is the cache there
-       if (isset($GLOBALS['cache_probe_nicknames'][$userid])) {
+       if (isset($GLOBALS['is_nickname_used'][$userid])) {
                // Then use it
-               $isUsed = $GLOBALS['cache_probe_nicknames'][$userid];
+               $isUsed = $GLOBALS['is_nickname_used'][$userid];
        } else {
                // Determine it
                $isUsed = ((isExtensionActive('nickname')) && (('' . round($userid) . '') != $userid));
 
                // And write it to the cache
-               $GLOBALS['cache_probe_nicknames'][$userid] = $isUsed;
+               $GLOBALS['is_nickname_used'][$userid] = $isUsed;
        }
 
        // Return the result
@@ -708,5 +708,49 @@ function setAdminHash ($admin, $hash) {
        $GLOBALS['cache_array']['admin']['password'][$admin] = $hash;
 }
 
+// Init user data array
+function initUserData () {
+       // User id should not be zero
+       if (getCurrentUserId() == 0) debug_report_bug('User id is zero.');
+
+       // Init the user
+       $GLOBALS['user_data'][getCurrentUserId()]['status'] = 'GUEST';
+}
+
+// Getter for user data
+function getUserData ($column) {
+       // User id should not be zero
+       if (getCurrentUserId() == 0) debug_report_bug('User id is zero.');
+
+       // Return the value
+       return $GLOBALS['user_data'][getCurrentUserId()][$column];
+}
+
+// Geter for whole user data array
+function gerUserDataArray () {
+       // Get the whole array
+       return $GLOBALS['user_data'];
+}
+
+// Checks if the user data is valid, this may indicate that the user has logged
+// in, but you should use isMember() if you want to find that out.
+function isUserDataValid () {
+       // User id should not be zero
+       if (getCurrentUserId() == 0) debug_report_bug('User id is zero.');
+
+       // Is the array there and filled?
+       return ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
+}
+
+// Setter for current userid
+function setCurrentUserId ($userid) {
+       $GLOBALS['current_userid'] = bigintval($userid);
+}
+
+// Getter for current userid
+function getCurrentUserId () {
+       return $GLOBALS['current_userid'];
+}
+
 // [EOF]
 ?>