New function fetchUserData() introduced to API, total rewrite (not all)
[mailer.git] / inc / modules / member / what-transfer.php
index 5c4db42a09e3f96e6f854eea4569b756227a2d50..2bbc1eeee18add4d0906cca71ea9261e59bc5a99 100644 (file)
@@ -52,19 +52,17 @@ if ((!isExtensionActive('transfer')) && (!isAdmin())) {
 } // END - if
 
 // Load data
-$result = SQL_QUERY_ESC("SELECT `opt_in` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-       array(getUserId()), __FILE__, __LINE__);
-list($opt_in) = SQL_FETCHROW($result);
-
-// Free memory
-SQL_FREERESULT($result);
+if (!fetchUserData(getUserId())) {
+       // Something really bad happened
+       debug_report_bug('No user account ' . getUserId() . ' found.');
+} // END - if
 
 // Check for mode in GET
 $mode = '';
 if (isGetRequestElementSet('mode')) $mode = getRequestElement('mode');
 
 // Check for "faker"
-if (($opt_in != 'Y') && ($mode == 'new')) $mode = '';
+if ((getUserData('opt_in') != 'Y') && ($mode == 'new')) $mode = '';
 
 switch ($mode) {
        case 'new': // Start new transfer
@@ -489,7 +487,7 @@ KEY (`party_userid`)
                                array(postRequestElement('opt_in'), getUserId()), __FILE__, __LINE__);
 
                        // Rember for next switch() command
-                       $opt_in = substr(postRequestElement('opt_in'), 0, 1);
+                       getUserData('opt_in') = substr(postRequestElement('opt_in'), 0, 1);
 
                        // "Settings saved..."
                        loadTemplate('admin_settings_saved', false, "<div class=\"member_done\">{--SETTINGS_SAVED--}</div>");
@@ -501,10 +499,10 @@ KEY (`party_userid`)
                } // END - foreach
 
                // Set current selection
-               $content['allow_' . strtolower($opt_in)] = ' checked="checked"';
+               $content['allow_' . strtolower(getUserData('opt_in'))] = ' checked="checked"';
 
                // Set 'new transfer' link according to above option
-               switch ($opt_in) {
+               switch (getUserData('opt_in')) {
                        case 'Y':
                                $content['new_link'] = "<a href=\"{?URL?}/modules.php?module=login&amp;what=transfer&amp;mode=new\">{--TRANSFER_NOW_LINK--}</a>";
                                break;