Handling of bonus points fixed
authorRoland Häder <roland@mxchange.org>
Fri, 29 Jul 2011 00:13:07 +0000 (00:13 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 29 Jul 2011 00:13:07 +0000 (00:13 +0000)
inc/daily/daily_100_bonus.php
inc/libs/bonus_functions.php
inc/libs/surfbar_functions.php
inc/libs/user_functions.php
inc/modules/admin/what-list_payouts.php
inc/modules/admin/what-unlock_emails.php
mailid_top.php

index 2b8e783868ddbe0e19a79978ff09f0596e0b7d9a..18a74623d040da1ecc7695d06503d870d26d8d19 100644 (file)
@@ -81,7 +81,7 @@ if (!SQL_HASZERONUMS($result_bonus)) {
        } // END - while
 
        // Handle bonus points
-       handleBonusPoints(getConfig('bonus_stats'));
+       handleBonusPoints(getConfig('bonus_stats'), $content['userid']);
 } // END - if
 
 // Free memory
index ef8b7144c7676ce5ce7cc860a16337a678d4bd65..7236987cad24dd561544159c2843e86fade70b03 100644 (file)
@@ -110,7 +110,7 @@ function addTurboBonus ($mid, $userid, $type) {
                ), __FUNCTION__, __LINE__);
 
        if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD') && ($points > 0)) {
-               handleBonusPoints($points);
+               handleBonusPoints($points, $userid);
        } // END - if
 }
 
@@ -203,8 +203,8 @@ LIMIT 1",
        return $OUT;
 }
 
-//
-function handleBonusPoints ($mode) {
+// Hanle any bonus points the given user shall become
+function handleBonusPoints ($mode, $userid) {
        // Shall we add bonus points?
        if (!isBonusRallyeActive()) {
                return;
@@ -214,7 +214,7 @@ function handleBonusPoints ($mode) {
        $return = false;
 
        // Switch to jackpot-mode when no UID is supplied but userid-mode is selected
-       if ((getBonusMode() == 'UID') && (getBonusUserid() == '0') && (isExtensionActive('jackpot'))) {
+       if ((getBonusMode() == 'UID') && ($userid == '0') && (isExtensionActive('jackpot'))) {
                // Update database & config
                updateConfiguration('bonus_mode', 'JACKPOT');
        } // END - if
@@ -228,7 +228,7 @@ function handleBonusPoints ($mode) {
        }
 
        // Check his amount first
-       $total = getTotalPoints(getBonusUserid());
+       $total = getTotalPoints($userid);
 
        // Subtract points from...
        switch (getBonusMode()) {
@@ -237,10 +237,10 @@ function handleBonusPoints ($mode) {
                        break;
 
                case 'JACKPOT': // ... jackpot
-                       if ((isExtensionActive('jackpot')) && (subtractPointsFromJackpot($points) === false) && (isValidUserId(getBonusUserid()))) {
+                       if ((isExtensionActive('jackpot')) && (subtractPointsFromJackpot($points) === false) && (isValidUserId($userid))) {
                                if ($total >= $points) {
                                        // Subtract points from userid's account
-                                       $return = subtractPointsFromJackpot('bonus_payout_jackpot', getBonusUserid(), $points);
+                                       $return = subtractPointsFromJackpot('bonus_payout_jackpot', $userid, $points);
                                } // END - if
                        } // END - if
                        break;
@@ -248,7 +248,7 @@ function handleBonusPoints ($mode) {
                case 'UID': // ... userid's account
                        if ($total >= $points) {
                                // Subtract points from userid's account
-                               $return = subtractPoints('bonus_payout_userid', getBonusUserid(), $points);
+                               $return = subtractPoints('bonus_payout_userid', $userid, $points);
                        } elseif (isExtensionActive('jackpot')) {
                                // Try to subtract from jackpot
                                $return = subtractPointsFromJackpot($points);
index d28a0ab1baed4eb9bae7079d43c1804c3fbb3d78..0199f568c5f7e0f98fd1cd5f9f247e5e7e5b710f 100644 (file)
@@ -978,16 +978,16 @@ LIMIT 1",
 // Check wether the user is allowed to book more URLs
 function SURFBAR_IF_USER_BOOK_MORE_URLS ($userid = NULL) {
        // Is this admin and userid is zero or does the user has some URLs left to book?
-       return ((($userid == '0') && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getSurfbarMaxOrder()));
+       return (((is_null($userid)) && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getSurfbarMaxOrder()));
 }
 
 // Get total amount of URLs of given status for current user
 function SURFBAR_GET_TOTAL_USER_URLS ($userid = NULL, $status = '', $exclude = '') {
        // Is the user 0 and user is logged in?
-       if (($userid == '0') && (isMember())) {
+       if ((is_null($userid)) && (isMember())) {
                // Then use this userid
                $userid = getMemberId();
-       } elseif ($userid == '0') {
+       } elseif (is_null($userid)) {
                // Error!
                return (getSurfbarMaxOrder() + 1);
        }
index 488e8f6f4f10143a3c88904bf0f365581f068dd8..33fa5067ceb38a1a224f049b956f914d6518b4e3 100644 (file)
@@ -333,7 +333,7 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
 
                                        // Subtract login bonus from userid's account or jackpot
                                        if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) {
-                                               handleBonusPoints('login_bonus');
+                                               handleBonusPoints('login_bonus', $userid);
                                        } // END - if
                                } // END - if
                        } // END - if
@@ -477,7 +477,7 @@ function getEpocheTimeFromUserStats ($statsType, $statsData, $userid = NULL) {
        $data['inserted'] = '0';
 
        // User id set?
-       if ((isMemberIdSet()) && ($userid == '0')) {
+       if ((isMemberIdSet()) && (is_null($userid))) {
                $userid = getMemberId();
        } // END - if
 
@@ -609,7 +609,7 @@ LIMIT 1",
                                                        array(bigintval($refid)), __FILE__, __LINE__);
 
                                                // Subtract points from system
-                                               handleBonusPoints(getConfig('bonus_ref'));
+                                               handleBonusPoints(getConfig('bonus_ref'), $refid);
                                        } // END - if
 
                                        // Add one-time referal bonus over referal system or directly
index 00d5a450aaa4812f091ae4f6db164e48957c88ea..dcb186be059e0eebcce761754f9a5b44c6b6bcb5 100644 (file)
@@ -45,7 +45,7 @@ addYouAreHereLink('admin', __FILE__);
 
 if (isGetRequestParameterSet('pid')) {
        // First let's get the member's id
-       $result = SQL_QUERY_ESC("SELECT userid, target_account, payout_total, payout_timestamp, password FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
+       $result = SQL_QUERY_ESC("SELECT `userid`, `target_account`, `payout_total`, `payout_timestamp`, `password` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
                array(getRequestParameter('pid')), __FILE__, __LINE__);
        list($userid, $tuserid, $points, $tstamp, $tpass) = SQL_FETCHROW($result);
        SQL_FREERESULT($result);
index 1d95092fa81bba5c0075b3654377962054579d38..555502ec7940506b322c428caf6fde76e94ddaba 100644 (file)
@@ -94,7 +94,7 @@ LIMIT 1",
                                                        array(bigintval($content['sender'])), __FILE__, __LINE__);
 
                                                // Subtract bonus points from system
-                                               handleBonusPoints(getConfig('bonus_order'));
+                                               handleBonusPoints(getConfig('bonus_order'), $content['sender']);
                                        } // END - if
 
                                        // Load email template
index 40ef802d4167751fd426cb85f85f11aeae111050..0ad68b00d53cbeb9357004b3ef793fe288b75e0d 100644 (file)
@@ -125,10 +125,14 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                        list($pool, $sender, $notify) = SQL_FETCHROW($result_mailid);
 
                        // Correct notification switch in non-bonus mails
-                       if (($notify != 'Y') && ($notify != 'N')) $notify = 'N';
+                       if (($notify != 'Y') && ($notify != 'N')) {
+                               $notify = 'N';
+                       } // END - if
 
                        // Set sender to 0 when we have a bonus mail
-                       if ($ltype == 'BONUS') $sender = '0';
+                       if ($ltype == 'BONUS') {
+                               $sender = '0';
+                       } // END - if
 
                        // Is the user id valid?
                        if (fetchUserData($userId) === true) {