More fixes for bonus ranking
[mailer.git] / inc / libs / bonus_functions.php
index 9cbf52d1ffb2ec2129d88b429ef04a2b499c3035..5b7358917ef5bec4e9a2ba12e4b24bdc0c207ee6 100644 (file)
@@ -73,7 +73,7 @@ function addTurboBonus ($mid, $userid, $type) {
        } // END - if
 
        // Check for entry
-       $rank = countSumTotalData($userid, 'bonus_turbo', 'id', 'userid', true, sprintf(" AND `%s`=%s", $column, $mid)) + 1;
+       $rank = countSumTotalData($mid, 'bonus_turbo', 'id', $column, true) + 1;
 
        // Which rank?
        if ($rank == 1) {
@@ -135,7 +135,7 @@ function addBonusRanks ($data, $type, $userid) {
                $GLOBALS['ranking_content']['yr_tmark']  = generateDateTime($GLOBALS['ranking_content']['timemark'], '1');
 
                // Load template
-               $GLOBALS['ranking_content']['rankings'] = loadTemplate('show_bonus_yr', true, $GLOBALS['ranking_content']);
+               $GLOBALS['ranking_content']['own'] = loadTemplate('show_bonus_yr', true, $GLOBALS['ranking_content']);
        } // END - if
 
        // Load rankings
@@ -151,31 +151,41 @@ function addBonusRanks ($data, $type, $userid) {
                // Output all ranks (levels)
                for ($rank = 1; $rank <= $max; $rank++) {
                        // Load data
-                       $result_users = SQL_QUERY_ESC("SELECT `userid`, `points`, `timemark` FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `%s`=%s AND level=%s LIMIT 1",
+                       $result_users = SQL_QUERY_ESC("SELECT
+       `userid`, `points`
+FROM
+       `{?_MYSQL_PREFIX?}_bonus_turbo`
+WHERE
+       `%s`=%s AND
+       `level`=%s
+LIMIT 1",
                                array($type, $data, $rank), __FUNCTION__, __LINE__);
 
                        // Nothing found by default
-                       $GLOBALS['ranking_content']['userid'] = '---';
-                       $GLOBALS['ranking_content']['points'] = '---';
+                       $rows['userid'] = '---';
+                       $rows['points'] = '---';
 
                        // Are you one of them?
                        if (SQL_NUMROWS($result_users) == 1) {
                                // Load data
-                               $GLOBALS['ranking_content'] = merge_array($GLOBALS['ranking_content'], SQL_FETCHARRAY($result_users));
+                               $rows = merge_array($rows, SQL_FETCHARRAY($result_users));
 
                                // Translate comma
-                               $GLOBALS['ranking_content']['points'] = translateComma($GLOBALS['ranking_content']['points']);
+                               $rows['points'] = translateComma($rows['points']);
                        } // END - if
 
+                       // Free result
+                       SQL_FREERESULT($result_users);
+
                        // Add more
-                       $GLOBALS['ranking_content']['rank'] = $rank;
-                       $GLOBALS['ranking_content']['sw']   = $SW;
+                       $rows['rank'] = $rank;
+                       $rows['sw']   = $SW;
 
                        // Output row
                        $OUT .= "<tr>
-  <td class=\"bonus_rank_".$GLOBALS['ranking_content']['rank']." bottom2 switch_sw".$GLOBALS['ranking_content']['sw']."\">&nbsp;".$GLOBALS['ranking_content']['rank'].".</td>
-  <td class=\"bonus_rank_".$GLOBALS['ranking_content']['rank']." bottom2 switch_sw".$GLOBALS['ranking_content']['sw']."\" align=\"center\">".$GLOBALS['ranking_content']['userid']."</td>
-  <td class=\"bonus_rank_".$GLOBALS['ranking_content']['rank']." bottom2 switch_sw".$GLOBALS['ranking_content']['sw']."\" align=\"center\">".$GLOBALS['ranking_content']['points']."</td>
+  <td class=\"bonus_rank_".$rows['rank']." bottom2 switch_sw".$rows['sw']."\">&nbsp;".$rows['rank'].".</td>
+  <td class=\"bonus_rank_".$rows['rank']." bottom2 switch_sw".$rows['sw']."\" align=\"center\">".$rows['userid']."</td>
+  <td class=\"bonus_rank_".$rows['rank']." bottom2 switch_sw".$rows['sw']."\" align=\"center\">".$rows['points']."</td>
 </tr>\n";
 
                        // Switch color