]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/rallye_functions.php
Naming convention applied to language strings, new API function added:
[mailer.git] / inc / libs / rallye_functions.php
index 62bc2a03cb787968e029177e92d21967b2bfb974..5aa0a1805cea0b682293eea8f3e348534ede309d 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;
@@ -464,7 +468,7 @@ function markReferalRallyesAsExpired ($result) {
                $prices['active'][$key] = $active;
 
                // Allow valid and active users with at least one ref to get points
-               if (($userid > 0) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
+               if ((isValidUserId($userid)) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
                        $total++;
                } // END - if
        } // END - foreach
@@ -482,7 +486,7 @@ function markReferalRallyesAsExpired ($result) {
        // Run array through (by userid is the most important 2nd-level-array)
        foreach($prices['userid'] as $key => $userid) {
                // Allow valid and active users with at least one ref to get points
-               if (($userid > 0) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0)) {
+               if ((isValidUserId($userid)) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0)) {
                        // Transfer data to array for the mail template
                        $DATA['level']  = $prices['level'][$key];
                        $DATA['points'] = $prices['points'][$key];
@@ -700,10 +704,7 @@ 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);
@@ -775,7 +776,7 @@ WHERE
        `expired`='Y'",
                array($EXPIRE), __FUNCTION__, __LINE__);
 
-       if (SQL_NUMROWS($result_rallye) > 0) {
+       if (!SQL_HASZERONUMS($result_rallye)) {
                // Init SQLs
                initSqls();
 
@@ -839,7 +840,7 @@ function addReferalRallyeTemplateSelection ($name = 'template', $default = '') {
        // Do we have found templates which we can link with the new rallye?
        if (!empty($ral[0])) {
                // Generate selection box for all found templates
-               $OUT  = '<select name="' . $name . '" size="1" class="admin_select">';
+               $OUT  = '<select name="' . $name . '" size="1" class="form_select">';
                $OUT .= generateOptionList('/ARRAY/', array_keys($ral), array_values($ral), $default, '', 'none');
                $OUT .= '</select>';
        } else {