]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-points.php
Huge rewrite of default parameters, ext-network continued:
[mailer.git] / inc / modules / member / what-points.php
index 947a9edefc0d044ad0f7c9d335434d4c92bb23f2..fc9ea3a66e0951f7a6b2c121d53f7db2fc85e489 100644 (file)
@@ -60,7 +60,7 @@ if (getExtensionVersion('bonus') >= '0.4.4') $depths += 4;
 $content['rowspan'] = ($depths*2+15);
 
 // Init some vars...
-$totalPoints = 0; $TREF = 0; $TLOCK = 0; $OUT = '';
+$totalPoints = '0'; $TREF = '0'; $TLOCK = '0'; $OUT = '';
 
 // Load ref levels
 while ($data = SQL_FETCHARRAY($result_depths)) {
@@ -68,10 +68,10 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
        $content = merge_array($content, $data);
 
        // Initialize ref-count
-       $REFS = 0;
+       $REFS = '0';
 
        // Load referal points
-       $result_points = SQL_QUERY_ESC("SELECT points, locked_points FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1", array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
+       $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1", array(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
        if (SQL_NUMROWS($result_points) == 1) {
                        list($points, $locked) = SQL_FETCHROW($result_points);
                // Also count locked points
@@ -84,13 +84,13 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
        SQL_FREERESULT($result_points);
 
        // Load referal counts
-       $result_refs = SQL_QUERY_ESC("SELECT counter FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND level='%s' LIMIT 1",
-               array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
+       $result_refs = SQL_QUERY_ESC("SELECT `counter` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND `level`='%s' LIMIT 1",
+               array(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
        if (SQL_NUMROWS($result_refs) == 1) {
                list($REFS) = SQL_FETCHROW($result_refs);
                $TREF += $REFS;
        } else {
-               $REFS = 0;
+               $REFS = '0';
        }
 
        // Free result
@@ -98,10 +98,10 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
 
        // Transfer data to array for template
        $row = array(
-               'level'   => $content['level'],
+               'level'    => $content['level'],
                'percents' => translateComma($content['percents']),
-               'points'  => translateComma($points),
-               'refs'    => translateComma($REFS),
+               'points'   => translateComma($points),
+               'refs'     => translateComma($REFS),
        );
 
        // Output row
@@ -114,10 +114,11 @@ SQL_FREERESULT($result_depths);
 // Put rows to constant for the main template
 $content['rows'] = $OUT;
 
-$result = SQL_QUERY_ESC("SELECT `used_points`, `ref_payout` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-       array(getUserId()), __FILE__, __LINE__);
-list($usedPoints, $PAY) = SQL_FETCHROW($result);
-SQL_FREERESULT($result);
+// Fetch user account
+if (!fetchUserData(getMemberId())) {
+       // Something really bad happened
+       debug_report_bug('User account ' . getMemberId() . ' not found.');
+} // END - if
 
 // Initialize variables
 $CONFIRMED = '---'; $SENT = '---'; $RECEIVED = '---';
@@ -125,12 +126,12 @@ $CONFIRMED = '---'; $SENT = '---'; $RECEIVED = '---';
 // Only user >= v0.1.2: Fetch confirmed mails counter
 if (getExtensionVersion('user') >= '0.1.2') {
        $add = '';
+       $CONFIRMED = getUserData('mails_confirmed');
+
        if (getExtensionVersion('user') >= '0.1.4') {
-               $add = ", `emails_sent`, `emails_received`";
-       }
-       $result = SQL_QUERY_ESC("SELECT `mails_confirmed`".$add." FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
-       list($CONFIRMED, $SENT, $RECEIVED) = SQL_FETCHROW($result);
-       SQL_FREERESULT($result);
+               $SENT     = getUserData('emails_sent');
+               $RECEIVED = getUserData('emails_received');
+       } // END - if
 
        // Please update the user extension if you see 3 dashes
        if (empty($SENT))     $SENT     = '---';
@@ -141,11 +142,11 @@ if (getExtensionVersion('user') >= '0.1.2') {
 }
 
 // If TLOCK is 0 add 3 zeros for floating
-if ($TLOCK == 0) $TLOCK = '0.00000';
+if ($TLOCK == '0') $TLOCK = '0.00000';
 
 // Remember several values in constants
-$content['used']  = translateComma($usedPoints);
-$content['tpts']  = translateComma($totalPoints - $usedPoints);
+$content['used']  = translateComma(getUserData('used_points'));
+$content['sum']   = translateComma($totalPoints - getUserData('used_points'));
 $content['tref']  = $TREF;
 $content['tlock'] = translateComma($TLOCK);
 
@@ -157,33 +158,34 @@ $content['special_rows'] = '';
 
 // Display login bonus and turbo-click bonus
 if ((getExtensionVersion('bonus') >= '0.2.2') && (isExtensionActive('bonus')) && (getConfig('bonus_active') == 'Y')) {
-       $add = ", 0, 0, 0";
-       if (getExtensionVersion('bonus') >= '0.4.4') $add = ", `bonus_ref`, `bonus_order`, `bonus_stats`";
-
-       // Load data
-       $result = SQL_QUERY_ESC("SELECT `login_bonus`, `turbo_bonus`".$add." FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-               array(getUserId()), __FILE__, __LINE__);
-
-       // We don't add this points now. This will be done after each month
-       list($login, $turbo, $ref, $order, $stats) = SQL_FETCHROW($result);
+       // Fetch some data and init others (to avoid a notice here)
+       $content['login'] = getUserData('login_bonus');
+       $content['turbo'] = getUserData('turbo_bonus');
+       $content['ref']   = '0.00000';
+       $content['order'] = '0.00000';
+       $content['stats'] = '0.00000';
+
+       // Get more data if ext-bonus is newer
+       if (getExtensionVersion('bonus') >= '0.4.4') {
+               $content['ref']   = getUserData('bonus_ref');
+               $content['order'] = getUserData('bonus_order');
+               $content['stats'] = getUserData('bonus_stats');
+       } // END - if
 
-       // Free result
-       SQL_FREERESULT($result);
+       // Total bonus points
+       $content['ttotal'] = translateComma($content['turbo'] + $content['login'] + $content['ref'] + $content['order'] + $content['stats']);
 
-       // Prepare constants
-       $content['turbo'] = translateComma($turbo);
-       $content['login'] = translateComma($login);
+       // Translate more data
+       $content['turbo'] = translateComma($content['turbo']);
+       $content['login'] = translateComma($content['login']);
 
        if (getExtensionVersion('bonus') >= '0.4.4') {
                // Add referal, stats and order bonys
-               $content['ref']   =  translateComma($ref);
-               $content['order'] = translateComma($order);
-               $content['stats'] = translateComma($stats);
+               $content['ref']   = translateComma($content['ref']);
+               $content['order'] = translateComma($content['order']);
+               $content['stats'] = translateComma($content['stats']);
        } // END - if
 
-       // Total bonus points
-       $content['ttotal'] = translateComma($turbo + $login + $ref + $order + $stats);
-
        // Output rows
        $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content);
 } elseif (getConfig('bonus_active') != 'Y') {
@@ -196,7 +198,7 @@ if ((getExtensionVersion('bonus') >= '0.2.2') && (isExtensionActive('bonus')) &&
 
 // Remeber values for the final template
 $content['receive']   = $RECEIVED;
-$content['pay']       = $PAY;
+$content['pay']       = getUserData('ref_payout');
 $content['confirmed'] = $CONFIRMED;
 $content['sent']      = $SENT;
 
@@ -214,7 +216,7 @@ if (isExtensionActive('user')) {
 
 if (isExtensionActive('payout')) {
        // Payput extension is installed and active so we can check if the user has enougth points
-       outputPayoutList(convertCommaToDot(($totalPoints - $usedPoints)));
+       outputPayoutList(convertCommaToDot(($totalPoints - getUserData('used_points'))));
 } // END - if
 
 // [EOF]