Fixes for mydata
[mailer.git] / inc / modules / member / what-mydata.php
index c18d46bc839925ed5696947f104624148d095660..17a435539a2faba819d62c536e24445c9687b91c 100644 (file)
@@ -51,8 +51,10 @@ if ((!isExtensionActive('mydata')) && (!isAdmin())) {
        return;
 } // END - if
 
-// Remember userid
-$content['userid'] = getUserId();
+// Add userid
+$content = array(
+       'userid' => getUserId()
+);
 
 // Init variable to prevent notices
 $URL = '';
@@ -66,15 +68,19 @@ if (isPostRequestElementSet('notify')) $mode = 'notify'; // Switch off notificat
 switch ($mode) {
        case 'show': // Show his data
                if (isExtensionActive('country', true)) {
-                       // New way                         0        1         2          3         4     5     6        7           8            9       10      11           12           13
-                       $result = SQL_QUERY_ESC("SELECT surname, family, street_nr, country_code, zip, city, email, birth_day, birth_month, birth_year, gender, max_mails, receive_mails, last_update FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
+                       // New way                          1          2            3             4         5      6        7           8            9              10         11         12               13            14
+                       $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `street_nr`, `country_code`, `zip`, `city`, `email`, `birth_day`, `birth_month`, `birth_year`, `gender`, `max_mails`, `receive_mails`, `last_update` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
                                array(getUserId()), __FILE__, __LINE__);
                } else {
-                       // Old way                         0        1         2        3      4     5     6        7           8            9       10      11           12           13
-                       $result = SQL_QUERY_ESC("SELECT surname, family, street_nr, country, zip, city, email, birth_day, birth_month, birth_year, gender, max_mails, receive_mails, last_update FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
+                       // Old way                          1          2            3        4         5      6        7           8            9              10         11         12               13            14
+                       $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `street_nr`, `country`, `zip`, `city`, `email`, `birth_day`, `birth_month`, `birth_year`, `gender`, `max_mails`, `receive_mails`, `last_update` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
                                array(getUserId()), __FILE__, __LINE__);
                }
-               $content = SQL_FETCHARRAY($result, 0, false);
+
+               // Get line
+               $content = merge_array($content, SQL_FETCHARRAY($result, 0, false));
+
+               // Free result
                SQL_FREERESULT($result);
 
                // Translate some things
@@ -103,9 +109,6 @@ switch ($mode) {
                        $content['country'] = generateCountryInfo($content['country_code']);
                } // END - if
 
-               // Merge data in
-               $content = merge_array($content, $content);
-
                // Load template
                loadTemplate('member_mydata_overview', false, $content);
                break;
@@ -131,8 +134,12 @@ LIMIT 1",
                                array(getUserId()), __FILE__, __LINE__);
                }
 
-               $content = SQL_FETCHARRAY($result, 0, false);
+               // Get line
+               $content = merge_array($content, SQL_FETCHARRAY($result, 0, false));
+
+               // Free result
                SQL_FREERESULT($result);
+
                $content['update_check'] = $content['last_update'] + getConfig('profile_lock');
 
                // How far is last change on his profile away from now?
@@ -188,9 +195,6 @@ LIMIT 1",
                                $content['country'] = "<input type=\"text\" name=\"cntry\" class=\"member_normal\" size=\"2\" maxlength=\"3\" value=\"".$content['country']."\" />";
                        }
 
-                       // Merge data in
-                       $content = merge_array($content, $content);
-
                        // Load template
                        loadTemplate('member_mydata_edit', false, $content);
                }
@@ -200,8 +204,13 @@ LIMIT 1",
                // Load old email / password:      0          1           2
                $result = SQL_QUERY_ESC("SELECT `email`, `password`, `last_update` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
                        array(getUserId()), __FILE__, __LINE__);
-               $content = SQL_FETCHARRAY($result, 0, false);
+
+               // Get line
+               $content = merge_array($content, SQL_FETCHARRAY($result, 0, false));
+
+               // Free result
                SQL_FREERESULT($result);
+
                $content['last_change'] = $content['last_update'] + getConfig('profile_lock');
 
                // How far is last change on his profile away from now?