Rewrites to use filters instead of mass if() blocks
[mailer.git] / inc / daily / daily_birthday.php
index 7085425d84012bf1f72eed49f5d0d3f849b36756..beae7944a22e7d32b1c66ee299641e55687683f1 100644 (file)
@@ -55,30 +55,38 @@ $day   = getDay();
 $month = getMonth();
 $year  = getYear();
 
-// Init variable
+// Init variables
 $lastOnline = '';
+$excludeSql = '';
 
 // Shall I include only active members?
 if ((getConfig('birthday_active')  == 'Y') && (isExtensionActive('autopurge')) && ((getApInactiveSince() > 0))) {
-       $add = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
+       $excludeSql = ' AND (UNIX_TIMESTAMP() - `d`.`last_online`) < {?ap_inactive_since?}';
+} // END - if
+
+// Is ext-holiday installed?
+// @TODO Rewrite these if() blocks to a filter
+if (isExtensionActive('holiday')) {
+       // Exclude those as well
+       $excludeSql .= " AND `d`.`holiday_active`='N'";
 } // END - if
 
 // Only confirmed members shall receive birthday mails...
 $result_birthday = SQL_QUERY_ESC("SELECT
-       `userid`,
-       `email`,
-       `birth_year`
+       `d`.`userid`,
+       `d`.`email`,
+       `d`.`birth_year`
 FROM
-       `{?_MYSQL_PREFIX?}_user_data`
+       `{?_MYSQL_PREFIX?}_user_data` AS `d`
 WHERE
-       `status`='CONFIRMED'
-       " . runFilterChain('user_exclusion_sql', ' ') . " AND
-       `birth_day`=%s AND
-       `birth_month`=%s AND
-       `birthday_sent` < (UNIX_TIMESTAMP() - ({?ONE_DAY?} * 364))
-       ".$lastOnline."
+       `d`.`status`='CONFIRMED'
+       " . runFilterChain('user_exclusion_sql', $excludeSql) . " AND
+       `d`.`birth_day`=%s AND
+       `d`.`birth_month`=%s AND
+       `d`.`birthday_sent` < (UNIX_TIMESTAMP() - ({?ONE_DAY?} * 364))
+       " . $lastOnline . "
 ORDER BY
-       `userid` ASC",
+       `d`.`userid` ASC",
        array($day, $month), __FILE__, __LINE__);
 
 if (!SQL_HASZERONUMS($result_birthday)) {