]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-points.php
Introduced template call-back function 'doTemplateAdminListUserTitle':
[mailer.git] / inc / modules / member / what-points.php
index 0fdd37c1305f53dcd8f79c021c508321070e5f4b..d83e597a0b820624b68c4a1d973287f129e5feab 100644 (file)
@@ -72,12 +72,26 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
        $content = merge_array($content, $data);
 
        // Initialize array elements
-       $content['counter'] = '0';
-       $content['points'] = '0.00000';
+       $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",
+       $result_points = SQL_QUERY_ESC("SELECT
+       p.`points`,
+       p.`locked_points`,
+       r.`counter`
+FROM
+       `{?_MYSQL_PREFIX?}_user_points` AS p
+INNER JOIN
+       `{?_MYSQL_PREFIX?}_refsystem` AS r
+ON
+       p.`userid`=r.`userid` AND
+       p.`ref_depth`=r.`level`
+WHERE
+       p.`userid`=%s AND
+       p.`ref_depth`='%s'
+LIMIT 1",
                array(
                        getMemberId(),
                        bigintval($content['level'])
@@ -88,27 +102,9 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
                // Load data
                $content = merge_array($content, SQL_FETCHARRAY($result_points));
 
-               // Add both points
-               $content['total_points'] += $content['points'];
-               $content['total_locked'] += $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__);
-
-       // Do we have an entry?
-       if (SQL_NUMROWS($result_refs) == 1) {
-               // Load data
-               $content = merge_array($content, SQL_FETCHARRAY($result_refs));
-
-               // Add them to total refs
+               // Add all entries
+               $content['total_points']   += $content['points'];
+               $content['total_locked']   += $content['locked_points'];
                $content['total_referals'] += $content['counter'];
        } // END - if
 
@@ -129,7 +125,9 @@ $content['rows'] = $OUT;
 $content['total_points']  = ($content['total_points'] - getUserData('used_points'));
 
 // Fixes a bug when there is no bonus extension installed
-if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', 'X');
+if (isExtensionInstalledAndOlder('bonus', '0.4.4')) {
+       setConfigEntry('bonus_active', 'X');
+} // END - if
 
 // Members shall see no special rows here
 $content['special_rows'] = '';