]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-points.php
Adding of request parameters partialy finished
[mailer.git] / inc / modules / member / what-points.php
index 523456832fc3e5efd3482c6c84d3b61ec5d588f7..38ae7595f088fd2ad529288bd355349add8a9663 100644 (file)
@@ -60,38 +60,56 @@ if (isExtensionInstalledAndNewer('bonus', '0.4.4')) $depths += 4;
 $content['rowspan'] = ($depths*2+15);
 
 // Init some vars...
-$totalPoints = '0'; $TREF = '0'; $TLOCK = '0'; $OUT = '';
+$totalPoints = '0';
+$totalReferals = '0';
+$totalLocked = '0';
+$OUT = '';
 
 // Load ref levels
 while ($data = SQL_FETCHARRAY($result_depths)) {
        // Merge it together
        $content = merge_array($content, $data);
 
-       // Initialize ref-count
-       $REFS = '0';
+       // Initialize array elements
+       $content['counter'] = '0';
+       $content['points'] = '0.00000';
+       $content['locked_points'] = '0.00000';
 
        // 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(getMemberId(), 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__);
+
+       // Do we have an entry?
        if (SQL_NUMROWS($result_points) == 1) {
-                       list($points, $locked) = SQL_FETCHROW($result_points);
-               // Also count locked points
-               $totalPoints += $points; $TLOCK += $locked;
-       } else {
-               $points = '0.00000'; $locked = '0.00000';
-       }
+               // Load data
+               $content = merge_array($content, SQL_FETCHARRAY($result_points));
+
+               // Add both points
+               $totalPoints += $content['points'];
+               $totalLocked += $content['locked_points'];
+       } // END - if
 
        // Free result
        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(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
+               array(
+                       getMemberId(),
+                       bigintval($content['level'])
+               ), __FILE__, __LINE__);
+
+       // Do we have an entry?
        if (SQL_NUMROWS($result_refs) == 1) {
-               list($REFS) = SQL_FETCHROW($result_refs);
-               $TREF += $REFS;
-       } else {
-               $REFS = '0';
-       }
+               // Load data
+               $content = merge_array($content, SQL_FETCHARRAY($result_refs));
+
+               // Add them to total refs
+               $totalReferals += $content['counter'];
+       } // END - if
 
        // Free result
        SQL_FREERESULT($result_refs);
@@ -100,8 +118,8 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
        $row = array(
                'level'    => $content['level'],
                'percents' => translateComma($content['percents']),
-               'points'   => translateComma($points),
-               'refs'     => translateComma($REFS),
+               'points'   => translateComma($content['points']),
+               'refs'     => translateComma($content['counter']),
        );
 
        // Output row
@@ -136,12 +154,12 @@ if (isExtensionInstalledAndNewer('user', '0.1.2')) {
 }
 
 // If TLOCK is 0 add 3 zeros for floating
-if ($TLOCK == '0') $TLOCK = '0.00000';
+if ($totalLocked == '0') $totalLocked = '0.00000';
 
 // Remember several values in constants
 $content['sum']   = translateComma($totalPoints - getUserData('used_points'));
-$content['tref']  = $TREF;
-$content['tlock'] = translateComma($TLOCK);
+$content['tref']  = $totalReferals;
+$content['tlock'] = translateComma($totalLocked);
 
 // Fixes a bug when there is no bonus extension installed
 if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', "X");