New function fetchUserData() introduced to API, total rewrite (not all)
[mailer.git] / inc / filters.php
index 3027b456ac09659e86c18114aaf2477f710062d1..5f6b9eed8424fb610d9d5f789149beb54ea59005 100644 (file)
@@ -285,21 +285,18 @@ function FILTER_UPDATE_LOGIN_DATA () {
        // Secure user id
        setUserId(getSession('userid'));
 
-       // Load last module and last online time
-       $result = SQL_QUERY_ESC("SELECT `last_module`, `last_online` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-               array(getUserId()), __FUNCTION__, __LINE__);
-
-       // Entry found?
-       if (SQL_NUMROWS($result) == 1) {
+       // Found a userid?
+       if (fetchUserData(getUserId())) {
                // Load last module and online time
-               $content = SQL_FETCHARRAY($result);
+               $content = getUserDataArray();
 
                // Maybe first login time?
                if (empty($content['last_module'])) $content['last_module'] = 'login';
 
                // This will be displayed on welcome page! :-)
                if (empty($GLOBALS['last_online']['module'])) {
-                       $GLOBALS['last_online']['module'] = $content['last_module']; $GLOBALS['last_online']['online'] = $content['last_online'];
+                       $GLOBALS['last_online']['module'] = $content['last_module'];
+                       $GLOBALS['last_online']['online'] = $content['last_online'];
                } // END - if
 
                // 'what' not set?
@@ -320,9 +317,6 @@ function FILTER_UPDATE_LOGIN_DATA () {
                // Destroy session, we cannot update!
                destroyUserSession();
        }
-
-       // Free the result
-       SQL_FREERESULT($result);
 }
 
 // Filter for initializing randomizer
@@ -372,11 +366,9 @@ function FILTER_DETERMINE_USERNAME () {
        // Check if logged in
        if (isMember()) {
                // Is still logged in so we welcome him with his name
-               $result = SQL_QUERY_ESC("SELECT `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-                       array(getUserId()), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1) {
+               if (fetchUserData(getUserId())) {
                        // Load surname and family's name and build the username
-                       $content = SQL_FETCHARRAY($result);
+                       $content = getUserDataArray();
 
                        // Prepare username
                        setUsername($content['surname'] . ' ' . $content['family']);
@@ -396,9 +388,6 @@ function FILTER_DETERMINE_USERNAME () {
                        // Kill userid
                        setUserId(0);
                }
-
-               // Free memory
-               SQL_FREERESULT($result);
        } elseif (isAdmin()) {
                // Admin is there
                setUsername('{--USERNAME_ADMIN--}');
@@ -494,7 +483,7 @@ function FILTER_UPDATE_EXTENSION_DATA ($ext_name) {
 // Load more reset scripts
 function FILTER_RUN_RESET_INCLUDES () {
        // Is the reset set or old sql_patches?
-       if (((!isResetModeEnabled()) || (!isExtensionInstalledAndOlder('sql_patches', '0.4.5'))) && (getOutputMode() == 0)) {
+       if (((!isResetModeEnabled()) || (!isExtensionInstalled('sql_patches'))) && (getOutputMode() == 0)) {
                // Then abort here
                logDebugMessage(__FUNCTION__, __LINE__, 'Cannot run reset! Please report this bug. Thanks');
        } // END - if
@@ -503,7 +492,7 @@ function FILTER_RUN_RESET_INCLUDES () {
        setIncludePool('reset', getArrayFromDirectory('inc/reset/', 'reset_'));
 
        // Update database
-       if ((!isConfigEntrySet('DEBUG_RESET')) || (getConfig('DEBUG_RESET') != 'Y')) updateConfiguration('last_update', time());
+       if ((!isConfigEntrySet('DEBUG_RESET')) || (getConfig('DEBUG_RESET') != 'Y')) updateConfiguration('last_update', 'UNIX_TIMESTAMP()');
 
        // Is the config entry set?
        if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) {