function classified_notifications_classified_notify_alter in Classified Ads 7.3
Same name and namespace in other branches
- 6.3 modules/classified_notifications/classified_notifications.module \classified_notifications_classified_notify_alter()
Implements hook_classified_notify_alter().
File
- modules/
classified_notifications/ classified_notifications.module, line 68 - Optional notification features for classified module.
Code
function classified_notifications_classified_notify_alter($ads_bunch, $kind) {
foreach ($ads_bunch as $uid => $ads) {
// TODO Convert "user_load" to "user_load_multiple" if "$uid" is not a uid.
// To return a single user object, wrap "user_load_multiple" with
// "array_shift" or equivalent.
// Example: array_shift(user_load_multiple(array(), $uid))
$account = user_load($uid);
$account->ads = $ads;
// Do not notify anonyms or users without mail.
if (!$account->uid || !$account->mail) {
continue;
}
$params['account'] = $account;
$message = drupal_mail('classified_notifications', $kind, $account->mail, user_preferred_language($account), $params, NULL, FALSE);
$job = array(
'description' => t('Classified Ads: lifetime notifications (@kind) for !name (@mail)', array(
'!name' => l($account->name, 'user/' . $account->uid),
'@kind' => $kind,
'@mail' => $account->mail,
)),
'key' => $kind,
'message' => $message,
);
$queue = DrupalQueue::get('classified_notifications', TRUE);
$queue
->createQueue();
$queue
->createItem($job);
}
}