]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/rallye_functions.php
Our convention says if(-else) blocks should not be put in one line
[mailer.git] / inc / libs / rallye_functions.php
index 1e1139e3a9b0f4365a3255a7cb65c69c9bdf622e..ca7e60fb54485d1b44931d4c2fcb8de472c457bd 100644 (file)
@@ -177,8 +177,8 @@ WHERE
 function addReferalRallyePrices ($rallye, $mode = 'email') {
        // Output mode
        switch($mode) {
-               case 'email': $mode = "\n";       break;
-               case 'html' : $mode = "<br />\n"; break;
+               case 'email': $mode = "\n";     break;
+               case 'html' : $mode = '<br />'; break;
        } // END - switch
 
        // Load prices
@@ -193,7 +193,7 @@ ORDER BY
                array($rallye), __FUNCTION__, __LINE__);
 
        // Entries found?
-       if (SQL_NUMROWS($result_prices) > 0) {
+       if (!SQL_HASZERONUMS($result_prices)) {
                // Load prices
                if ($mode == "\n") $prices = '{--RALLYE_MEMBER_PRICES_ADDED--}:' . $mode . '------------------------------' . $mode;
 
@@ -293,7 +293,11 @@ LIMIT 1",
 
                // List only users with at least one ref!
                //* DEBUG: */ debugOutput('*'.$cnt.'/'.$content['userid'].'/'.$content['curr_points'].'/'.$refpoints.'*');
-               if (($cnt > 0) && ($refpoints > $content['curr_points'])) { $userid = $content['userid']; } else { $cnt = ''; }
+               if (($cnt > 0) && ($refpoints > $content['curr_points'])) {
+                       $userid = $content['userid'];
+               } else {
+                       $cnt = '';
+               }
 
                // Save values to array
                $DATA['userid'][]   = $userid;
@@ -311,7 +315,6 @@ LIMIT 1",
 
        // Generate table
        $OUT = '';
-       $SW = 2;
        for ($idx = '0'; $idx < $prices; $idx++) {
                // Prepare marking of default (maybe current user's) id
                $start = ''; $end = '';
@@ -322,7 +325,6 @@ LIMIT 1",
 
                // Prepare content
                $content = array(
-                       'sw'     => $SW,
                        'idx'    => ($idx + 1),
                        'start'  => $start,
                        'end'    => $end,
@@ -333,7 +335,6 @@ LIMIT 1",
 
                // Load row template and switch color
                $OUT .= loadTemplate('guest_rallye_row', true, $content);
-               $SW = 3 - $SW;
        } // END - for
 
        // Add min_prices/users
@@ -703,16 +704,13 @@ LIMIT 1",
 // @TODO This function does not load min_users, min_prices, please encapsulate loading rallye data with e.g. getRallyeDataFromId()
 function addReferalRallyeWinners ($rallye, $default=0) {
        // First check how many prices are set
-       $result_prices = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s ORDER BY `price_level` ASC",
-               array(bigintval($rallye)), __FUNCTION__, __LINE__);
-       $prices = SQL_NUMROWS($result_prices);
-       SQL_FREERESULT($result_prices);
+       $prices = countSumTotalData(bigintval($rallye), 'rallye_prices', 'id', 'rallye_id', true);
 
        // Load data
        $DATA = getArrayFromReferalRallyeUsers($rallye);
 
        // Generate table
-       $OUT = ''; $SW = 2;
+       $OUT = '';
        for ($idx = '0'; $idx < $prices; $idx++) {
                // Check status
                //   active = 1: account is still confirmed
@@ -742,7 +740,6 @@ function addReferalRallyeWinners ($rallye, $default=0) {
 
                // Prepare content
                $content = array(
-                       'sw'     => $SW,
                        'idx'    => ($idx + 1),
                        'userid' => $DATA['userid'][$idx],
                        'ref'    => $DATA['ref'][$idx],
@@ -753,7 +750,6 @@ function addReferalRallyeWinners ($rallye, $default=0) {
 
                // Load row template
                $OUT .= loadTemplate('guest_rallye_row', true, $content);
-               $SW = 3 - $SW;
        } // END - for
 
        // Prepare content
@@ -780,7 +776,7 @@ WHERE
        `expired`='Y'",
                array($EXPIRE), __FUNCTION__, __LINE__);
 
-       if (SQL_NUMROWS($result_rallye) > 0) {
+       if (!SQL_HASZERONUMS($result_rallye)) {
                // Init SQLs
                initSqls();