Way more usage of EL code:
[mailer.git] / inc / libs / bonus_functions.php
index a4a9c2189560f8815a21cdbfbe550801bcee7851..7bbf24eee983e811db0bffb3a7823024e3065260 100644 (file)
@@ -40,10 +40,12 @@ if (!defined('__SECURITY')) {
        die();
 } // END - if
 
-// This function must be run *BEFORE* a link is removed from table 'mxchange_user_links' !
+// This function must be run *BEFORE* a link is removed from table 'mailer_user_links' !
 function addTurboBonus ($mid, $userid, $type) {
        // Shall we add bonus points?
-       if (!isBonusRallyeActive()) return false;
+       if (!isBonusRallyeActive()) {
+               return false;
+       } // END - if
 
        // Init variables
        $sql = ''; $bonus = '0'; $mail = '0'; $column = '';
@@ -85,7 +87,7 @@ function addTurboBonus ($mid, $userid, $type) {
                        // Level found
                        $points = $test[$rank - 2];
                } else {
-                       // Level not found!
+                       // Level not found
                        $points = '0.00000';
                }
        }
@@ -197,11 +199,11 @@ LIMIT 1",
                        $GLOBALS['ranking_content']['rankings'] = '{--MEMBER_BONUS_RANK_YOU_ARE_404--}';
                } // END - if
        } else {
-               // No entries found!
+               // No entries found
                // @TODO Move this HTML to a template
                $OUT = '<tr>
   <td colspan="3" align="center" height="30" class="bottom">
-    <div class="notice">' . getMaskedMessage('MEMBER_BONUS_NO_RANKS', $data) . '</div>
+    <div class="notice">{%message,MEMBER_BONUS_NO_RANKS=' . $data . '%}</div>
   </td>
 </tr>';
        }
@@ -216,7 +218,7 @@ function handleBonusPoints ($mode) {
        if (!isBonusRallyeActive()) return;
 
        // Switch to jackpot-mode when no UID is supplied but userid-mode is selected
-       if ((getBonusMode() == 'UID') && (getBonusUserId() == '0') && (isExtensionActive('jackpot'))) {
+       if ((getBonusMode() == 'UID') && (getBonusUserid() == '0') && (isExtensionActive('jackpot'))) {
                // Update database & config
                updateConfiguration('bonus_mode', 'JACKPOT');
        } // END - if
@@ -230,7 +232,7 @@ function handleBonusPoints ($mode) {
        }
 
        // Check his amount first
-       $total = getTotalPoints(getBonusUserId());
+       $total = getTotalPoints(getBonusUserid());
 
        // Subtract points from...
        switch (getBonusMode()) {
@@ -239,10 +241,10 @@ function handleBonusPoints ($mode) {
                        break;
 
                case 'JACKPOT': // ... jackpot
-                       if ((isExtensionActive('jackpot')) && (subtractPointsFromJackpot($points) == -1) && (isValidUserId(getBonusUserId()))) {
+                       if ((isExtensionActive('jackpot')) && (subtractPointsFromJackpot($points) == -1) && (isValidUserId(getBonusUserid()))) {
                                if ($total >= $points) {
                                        // Subtract points from userid's account
-                                       subtractPointsFromJackpot('bonus_payout_jackpot', getBonusUserId(), $points);
+                                       subtractPointsFromJackpot('bonus_payout_jackpot', getBonusUserid(), $points);
                                } // END - if
                        } // END - if
                        break;
@@ -250,7 +252,7 @@ function handleBonusPoints ($mode) {
                case 'UID': // ... userid's account
                        if ($total >= $points) {
                                // Subtract points from userid's account
-                               subtractPoints('bonus_payout_userid', getBonusUserId(), $points);
+                               subtractPoints('bonus_payout_userid', getBonusUserid(), $points);
                        } elseif (isExtensionActive('jackpot')) {
                                // Try to subtract from jackpot
                                $dummy = subtractPointsFromJackpot($points);
@@ -266,7 +268,7 @@ function handleBonusPoints ($mode) {
 // Purges expired fast-click bonus entries
 function purgeExpiredTurboBonus() {
        // Remove entries
-       $result = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `timemark` < (UNIX_TIMESTAMP() - {?bonus_timeout?})', __FUNCTION__, __LINE__);
+       $result = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE (UNIX_TIMESTAMP() - `timemark`) >= {?bonus_timeout?}', __FUNCTION__, __LINE__);
 
        if (!SQL_HASZEROAFFECTED()) {
                // Send out email to admin
@@ -274,49 +276,6 @@ function purgeExpiredTurboBonus() {
        } // END - if
 }
 
-//-----------------------------------------------------------------------------
-//                                Filter Functions
-//-----------------------------------------------------------------------------
-
-// Filter for adding login bonus to the user's account
-function FILTER_ADD_LOGIN_BONUS () {
-       // Is the user data valid?
-       if (!isMember()) {
-               // Do only run for logged in members
-               debug_report_bug(__FUNCTION__, __LINE__, 'Please only run this filter for logged in users.');
-       } // END - if
-
-       // Bonus is not given by default ;-)
-       $bonus = false;
-       if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (isBonusRallyeActive()) && (getConfig('bonus_login_yn') == 'Y')) {
-               // Update last login if far enougth away
-               // @TODO This query isn't right, it will only update if the user was for a longer time away!
-               SQL_QUERY_ESC('UPDATE
-       `{?_MYSQL_PREFIX?}_user_data`
-SET
-       `last_login`=UNIX_TIMESTAMP()
-WHERE
-       `userid`=%s AND
-       `last_login` < (UNIX_TIMESTAMP() - {?login_timeout?})
-LIMIT 1',
-                       array(
-                               getMemberId()
-                       ), __FUNCTION__, __LINE__
-               );
-
-               // Updated entry?
-               $bonus = (!SQL_HASZEROAFFECTED());
-       } // END - if
-
-       if (($bonus === true) && (getRequestParameter('mode') == 'bonus')) {
-               // Output message with added points
-               $GLOBALS['message'] .= '<div class="tiny">{--MEMBER_BONUS_LOGIN_BONUS_ADDED--}</div>';
-       } elseif (isExtensionActive('bonus')) {
-               // No login bonus added!
-               $GLOBALS['message'] .= '<div class="notice">{--MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED--}</div>';
-       }
-}
-
 //-----------------------------------------------------------------------------
 //                             Wrapper Functions
 //-----------------------------------------------------------------------------