]> git.mxchange.org Git - mailer.git/blobdiff - inc/daily/daily_birthday.php
This 'return FALSE' caused that the PHP's error handler was called :( So, do NEVER...
[mailer.git] / inc / daily / daily_birthday.php
index 3ecad9d80ff020fae2702a605274aaadfae2d6af..ae3b57134a08aa7f5cbf81cb54f9278d51fb654b 100644 (file)
@@ -16,8 +16,8 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -42,6 +42,7 @@ if (!defined('__SECURITY')) {
        // Do not execute when script is in CSS mode
        return;
 } elseif (!isExtensionActive('birthday')) {
+       // Extension not active/installed
        logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
        return;
 }
@@ -54,25 +55,31 @@ $day   = getDay();
 $month = getMonth();
 $year  = getYear();
 
+// Init variable
+$lastOnline = '';
+
 // Shall I include only active members?
-$add = '%s'; $value = '';
-if ((getConfig('birthday_active')) && (isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getApInactiveSince() > 0)) {
-       $add = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})";
+if ((getConfig('birthday_active')  == 'Y') && (isExtensionActive('autopurge')) && ((getApInactiveSince() > 0))) {
+       $add = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
 } // END - if
 
 // Only confirmed members shall receive birthday mails...
-$result_birthday = SQL_QUERY_ESC("SELECT `userid`, `email`, `birth_year`
+$result_birthday = SQL_QUERY_ESC("SELECT
+       `userid`,
+       `email`,
+       `birth_year`
 FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
-       `status`='CONFIRMED' AND
+       `status`='CONFIRMED'
+       " . runFilterChain('user_exclusion_sql', ' ') . " AND
        `birth_day`=%s AND
        `birth_month`=%s AND
        `birthday_sent` < (UNIX_TIMESTAMP() - ({?ONE_DAY?} * 364))
-       ".$add."
+       ".$lastOnline."
 ORDER BY
        `userid` ASC",
-       array($day, $month, $value), __FILE__, __LINE__);
+       array($day, $month), __FILE__, __LINE__);
 
 if (!SQL_HASZERONUMS($result_birthday)) {
        // Start sending out birthday mails
@@ -84,13 +91,13 @@ if (!SQL_HASZERONUMS($result_birthday)) {
                // Simply subtract both values and you got the age... :)
                $age = $now - $bd;
 
-               if (getConfig('birthday_points') > 0) {
+               if (getBirthdayPoints() > 0) {
                        // Add more entries to the array
                        $content['age']    = $age;
                        $content['check']  = '';
 
                        // @TODO 4 is hard-coded here, should we move it out in config?
-                       for ($idx = '0'; $idx < 4; $idx++) {
+                       for ($idx = 0; $idx < 4; $idx++) {
                                $content['check'] .= generateRandomCode('8', mt_rand(0, $month . $day), $content['userid'], ($age * ($idx + 1)));
                        } // END - for
 
@@ -105,11 +112,11 @@ if (!SQL_HASZERONUMS($result_birthday)) {
                        $message = loadEmailTemplate('member_birthday_confirm', $content, bigintval($content['userid']));
                } else {
                        // Load default email template and fill in the age
-                       $message = loadEmailTemplate('member_birthday', $age, $content['userid']);
+                       $message = loadEmailTemplate('member_birthday', $content, $content['userid']);
                }
 
                // Send email
-               sendEmail($content['email'], '{--MEMBER_HAPPY_BIRTHDAY_SUBJECT--}', $message);
+               sendEmail($content['userid'], '{--MEMBER_HAPPY_BIRTHDAY_SUBJECT--}', $message);
 
                // Remember him that he has received a birthday mail
                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `birthday_sent`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",