]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-primera.php
Comments fixed, ext-network continued, fix for mod stats:
[mailer.git] / inc / modules / member / what-primera.php
index 4088ab3b1ad618560546706f280c8a5f930d0f8e..2a1322dbee11f5106ae0d3a870aa66bec457b8d9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 09/09/2008 *
- * ================                             Last change: 09/09/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 09/09/2008 *
+ * ===================                          Last change: 09/09/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-primera.php                                 *
@@ -69,39 +69,32 @@ if (!isGetRequestElementSet('mode')) {
        // Get referal id
        $content['refid'] = getConfig(('primera_refid'));
 
-       // Get Primus id
-       $result = SQL_QUERY_ESC("SELECT `primera_userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-               array(getUserId()), __FILE__, __LINE__);
-
        // Are there some entries?
-       if (SQL_NUMROWS($result) == 1) {
-               // Fetch ID
-               list($content['primera_nickname']) = SQL_FETCHROW($result);
+       if (fetchUserData(getMemberId())) {
+               // Fetch id
+               $content['primera_nickname'] = getUserData('primera_nickname');
        } // END - if
 
-       // Free result
-       SQL_FREERESULT($result);
-
-       // Is there an ID?
+       // Is there an id?
        if ((!empty($content['primera_nickname'])) && (!isGetRequestElementSet('mode'))) {
                // Then use an other "mode"
                setRequestGetElement('mode', 'list');
 
                // And load all rows!
-               $result = SQL_QUERY_ESC("SELECT `id`,`primera_account`,`primera_amount`,`primera_timestamp`,`primera_type` FROM `{?_MYSQL_PREFIX?}_user_primera` WHERE `userid` = %s ORDER BY `primera_timestamp` DESC",
-                       array(getUserId()), __FILE__, __LINE__);
+               $result = SQL_QUERY_ESC("SELECT `id`,`primera_account`,`primera_amount`,`primera_timestamp`,`primera_type` FROM `{?_MYSQL_PREFIX?}_user_primera` WHERE `userid`=%s ORDER BY `primera_timestamp` DESC",
+                       array(getMemberId()), __FILE__, __LINE__);
 
                // Load all rows
                $content['rows'] = ''; $SW = 2;
                while ($data = SQL_FETCHARRAY($result)) {
                        // Prepare data for output
                        $rowContent = array(
-                               'stamp'         => generateDateTime($data['primera_timestamp'], '2'),
-                               'points'                => translateComma($data['primera_amount']),
-                               'acc'           => SQL_ESCAPE($data['primera_account']),
-                               'status'                => PRIMERA_TRANSFER_STATUS($data['primera_type']),
-                               'raw_type'      => strtolower($data['primera_type']),
-                               'sw'                    => $SW,
+                               'primera_timestamp' => generateDateTime($data['primera_timestamp'], 2),
+                               'points'            => translateComma($data['primera_amount']),
+                               'primera_account'   => SQL_ESCAPE($data['primera_account']),
+                               'status'            => PRIMERA_TRANSFER_STATUS($data['primera_type']),
+                               'raw_type'          => strtolower($data['primera_type']),
+                               'sw'                => $SW,
                        );
 
                        // Load row template
@@ -119,7 +112,7 @@ if (!isGetRequestElementSet('mode')) {
 
 if (getRequestElement('mode') == 'pay') {
        // Get total points and check if the user can request a payout
-       $points = countSumTotalData(getUserId(), 'user_points', 'points') - countSumTotalData(getUserId(), 'user_data', 'used_points');
+       $points = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
 
        // No dots here...
        $points = explode('.', $points);
@@ -141,17 +134,12 @@ if (getRequestElement('mode') == 'pay') {
 
        // Get Primera id
        $content['primera_nickname'] = '';
-       $result = SQL_QUERY_ESC("SELECT `primera_userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-               array(getUserId()), __FILE__, __LINE__);
-
-       // Are there some entries?
-       if (SQL_NUMROWS($result) == 1) {
-               // Fetch ID
-               list($content['primera_nickname']) = SQL_FETCHROW($result);
-       }
 
-       // Free result
-       SQL_FREERESULT($result);
+       // Do we have a user account? (should be!)
+       if (fetchUserData(getMemberId())) {
+               // Fetch id
+               $content['primera_nickname'] = getUserData('primera_nickname');
+       } // END - if
 } else {
        // Invalid mode!
        loadTemplate('admin_settings_saved', false, sprintf(getMessage('PRIMERA_MEMBER_MODE_INVALID'), getRequestElement('mode')));
@@ -163,7 +151,7 @@ if ((isFormSent()) && (isGetRequestElementSet('mode'))) {
        // Check input data depending on the mode and execute the requested mode
        switch (getRequestElement('mode')) {
                case 'pay': // Payout this exchange -> Primus
-                       // Is the user ID and password set?
+                       // Is the user id and password set?
                        if (!isPostRequestElementSet(('primera_nickname'))) {
                                // Nothing entered in Primus nickname
                                loadTemplate('admin_settings_saved', false, getMessage('PRIMERA_MEMBER_EMPTY_USERNAME'));
@@ -196,11 +184,11 @@ if ((isFormSent()) && (isGetRequestElementSet('mode'))) {
                                        } // END - if
 
                                        // Remove points from account
-                                       subtractPoints('primera_payout', getUserId(), postRequestElement('amount'));
+                                       subtractPoints('primera_payout', getMemberId(), postRequestElement('amount'));
 
                                        // Update primera nickname
-                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `primera_userid`=%s WHERE `userid`=%s LIMIT 1",
-                                               array(postRequestElement('primera_nickname'), getUserId()), __FILE__, __LINE__);
+                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `primera_nickname`=%s WHERE `userid`=%s LIMIT 1",
+                                               array(postRequestElement('primera_nickname'), getMemberId()), __FILE__, __LINE__);
 
                                        // All done!
                                        loadTemplate('admin_settings_saved', false, getMessage('PRIMERA_MEMBER_PAYOUT_DONE'));