function _birthdays_send_user_message in Birthdays 5
Same name and namespace in other branches
- 6 birthdays.mail.inc \_birthdays_send_user_message()
Send all birthdays on this day a message
@todo re-introduce the postcard module to make it fun
1 call to _birthdays_send_user_message()
- birthdays_cron in ./
birthdays.module - Implementation of hook_cron().
File
- ./
birthdays.module, line 1248 - The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an e-mail on their birthday automatically, and the administrator can receive daily reminders of…
Code
function _birthdays_send_user_message() {
// If messaging is enabled
if (variable_get('birthdays_send_user', BIRTHDAYS_USER_MAIL_NO) > BIRTHDAYS_USER_MAIL_NO) {
// Get all users having their birthday today
$accounts = birthdays_get_todays_birthdays();
// Get site address
$from = variable_get('site_mail', ini_get('sendmail_from'));
$subject = variable_get('birthdays_send_user_subject', t('Happy Birthday!'));
$message = variable_get('birthdays_send_user_message', t("Hey @name,\nHappy birthday!\nHope you have a great day!"));
foreach ($accounts as $uid) {
// Load user
$account = user_load(array(
'uid' => $uid,
));
// If user and/or administrator allow sending messages
if (variable_get('birthdays_send_user', BIRTHDAYS_USER_MAIL_NO) == BIRTHDAYS_USER_MAIL_YES || variable_get('birthdays_send_user', BIRTHDAYS_USER_MAIL_NO) == 2 && $account->birthdays_user_send_mail != BIRTHDAYS_USER_MAIL_USER_NO) {
// Replace @name in message by username
$parsed_message = strtr($message, array(
'@name' => check_plain($account->name),
));
// Send mail
drupal_mail('birthdays_user_message', $account->name . ' <' . $account->mail . '>', $subject, $parsed_message, $from);
// Log actions
watchdog('Birthdays', t('Sent @name a birthday e-mail.', array(
'@name' => $account->name,
)), WATCHDOG_NOTICE, ' ');
}
}
}
}