function newsletter_feedback in Newsletter 7
Same name and namespace in other branches
- 7.2 newsletter.module \newsletter_feedback()
Feedback to site administrator depending on newsletter send status.
Parameters
$statuses: An array containing status values set when a newsletter mail was sent.
2 calls to newsletter_feedback()
- newsletter_cron in ./
newsletter.module - Implements hook_cron().
- newsletter_node_insert in ./
newsletter.module - Implements hook_node_insert().
File
- ./
newsletter.module, line 1272 - Defines menu items for newsletter administration, permissions and basic drupal hooks.
Code
function newsletter_feedback($statuses) {
if (is_array($statuses) && !empty($statuses)) {
$success = 0;
$error = 0;
$no_items = 0;
$no_subs = 0;
foreach ($statuses as $status) {
$status = $status === 1 || $status === TRUE ? 'success' : $status;
switch ($status) {
case 'No subscribers':
$no_subs++;
break;
case 'No items':
$no_items++;
break;
case 'success':
$success++;
break;
default:
$error++;
}
}
if ($no_subs) {
watchdog('newsletter', '%no_subs Newsletter Lists failed to send because no subscribers found subscribed to them', array(
'%no_subs' => $no_subs,
));
}
if ($no_items) {
watchdog('newsletter', '%no_items Newsletter Lists failed to send because no published nodes found for their terms', array(
'%no_items' => $no_items,
));
}
if ($success) {
watchdog('newsletter', '%success Newsletter Lists sent', array(
'%success' => $success,
));
}
if ($error) {
watchdog('newsletter', '%error Newsletter Lists failed to send.Check previous watchdog notices for more info', array(
'%error' => $error,
), WATCHDOG_ERROR);
}
}
return;
}