]> git.mxchange.org Git - mailer.git/blobdiff - inc/monthly/monthly_beg.php
Rewrites to use filters instead of mass if() blocks
[mailer.git] / inc / monthly / monthly_beg.php
index 75e58be8d8c1f9fbf1cbddf00493bae217c654a6..893b2e0609d4ff0b725e0bf25d101608adb3ae74 100644 (file)
 // Some security stuff...
 if (!defined('__SECURITY')) {
        die();
-} elseif ((isCssOutputMode()) || (!isResetModeEnabled())) {
-       // Do not execute when script is in CSS mode or no hourly reset
+} elseif ((!isHtmlOutputMode()) || (!isMonthlyResetEnabled())) {
+       // Do not execute when script is in non-HTML mode or no hourly reset
        return;
-} elseif (((!isExtensionActive('beg')) || (!isBegRallyeEnabled())) && (isDebugModeEnabled())) {
-       logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension ext-beg disabled.');
+} elseif ((!isExtensionActive('beg')) || (!isBegRallyeEnabled())) {
+       if (isDebugModeEnabled()) logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension ext-beg disabled.');
        return;
 }
 
@@ -55,31 +55,38 @@ if ((getBegRanks() > 0) && (!isCssOutputMode())) {
        $whereStatement = '';
 
        // Shall we exclude webmaster's own userid?
+       // @TODO Rewrite these if() blocks to a filter
        if ((!isBegIncludeOwnEnabled()) && (isValidId(getBegUserid()))) {
                // Exclude it
-               $whereStatement .= ' AND `userid` != {?beg_userid?}';
+               $whereStatement .= ' AND `d`.`userid` != {?beg_userid?}';
        } // END - if
 
        // Let's check if there are some points left we can pay...
        if ((isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) {
                // Okay, include last online timestamp
-               $whereStatement .= ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
+               $whereStatement .= ' AND (UNIX_TIMESTAMP() - `d`.`last_online`) < {?ap_inactive_since?}';
+       } // END - if
+
+       // Is ext-holiday installed?
+       if (isExtensionActive('holiday')) {
+               // Exclude those as well
+               $whereStatement .= " AND `d`.`holiday_active`='N'";
        } // END - if
 
        // SQL string to check for accounts
        $result_main = SQL_QUERY("SELECT
-       `userid`,
-       `beg_points`
+       `d`.`userid`,
+       `d`.`beg_points`
 FROM
-       `{?_MYSQL_PREFIX?}_user_data`
+       `{?_MYSQL_PREFIX?}_user_data` AS `d`
 WHERE
-       `status`='CONFIRMED'
+       `d`.`status`='CONFIRMED'
        " . $whereStatement . "
        " . runFilterChain('user_exclusion_sql', ' ') . " AND
-       `beg_points` > 0
+       `d`.`beg_points` > 0
 ORDER BY
-       `beg_points` DESC,
-       `userid` ASC
+       `d`.`beg_points` DESC,
+       `d`.`userid` ASC
 LIMIT {?beg_ranks?}", __FILE__, __LINE__);
 
        if (!SQL_HASZERONUMS($result_main)) {