X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffilter%2Frallye_filter.php;h=2965cc5acc432f2ba5d7558b187302618ec14df1;hp=24d09ba745482415401b918d13bc85f4f29e8414;hb=2df9f7a53f8b1dd5164f87824a324ccb3b6634cb;hpb=63f159414369b5ea19a8ca75d8cd8033c45d8341 diff --git a/inc/filter/rallye_filter.php b/inc/filter/rallye_filter.php index 24d09ba745..2965cc5acc 100644 --- a/inc/filter/rallye_filter.php +++ b/inc/filter/rallye_filter.php @@ -51,5 +51,86 @@ function FILTER_RALLYE_EXTRA_AUTOPURGE ($filterData) { return $filterData; } +// Run filter for notifying users about rallyes +function FILTER_RALLYE_NOTIFY_USERS ($filterData) { + // Do stuff only when not in CSS mode + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + if (!isCssOutputMode()) { + // Run filter to get SQL "addons" + $sqlAddons = runFilterChain('add_rallye_notify_sqls', array( + 'add' => '', + 'or' => '' + )); + + // Check for new started but not notified rallyes + $result = SQL_QUERY("SELECT SQL_SMALL_RESULT + d.`id`, + d.`title`, + d.`start_time`, + d.`end_time`, + d.`send_notify` + " . $sqlAddons['add'] . " +FROM + `{?_MYSQL_PREFIX?}_rallye_data` AS d +WHERE + d.`is_active`='Y' AND + d.`notified`='N' AND + d.`expired`='N' AND + d.`start_time` <= UNIX_TIMESTAMP() AND + d.`end_time` > UNIX_TIMESTAMP() +LIMIT 1", __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Start rallye + autostartReferralRallyes($result); + } // END - if + + // Free memory + SQL_FREERESULT($result); + + // Check for expired rallyes + $result = SQL_QUERY("SELECT SQL_SMALL_RESULT + d.`id`, + d.`title`, + d.`start_time`, + d.`end_time`, + d.`send_notify` + " . $sqlAddons['add'] . " +FROM + `{?_MYSQL_PREFIX?}_rallye_data` AS d +WHERE + d.`is_active`='Y' AND + d.`notified`='Y' AND + d.`expired`='N' AND + (d.`end_time` <= UNIX_TIMESTAMP()" . $sqlAddons['or'] . ") +LIMIT 1", __FILE__, __LINE__); + if ((SQL_NUMROWS($result) == 1) && (isExtensionActive('autopurge'))) { + // End rallye here... + stopRallyeByResult($result); + } // END - if + + // Free memory + SQL_FREERESULT($result); + } // END - if + + // Return data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for adding SQL columns +function FILTER_ADD_RALLYE_SQL_COLUMNS ($filterData) { + // Are all requirements met? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + if (isExtensionInstalledAndNewer('rallye', '0.2.0')) { + // Add more data on higher versions + $filterData['add'] .= ',`min_users`, `min_prices`'; + $filterData['or'] .= ' OR (d.`min_users` <= ' . getTotalConfirmedUser() . ' AND d.`min_users` > 0)'; + } // END - if + + // Return data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + // [EOF] ?>