You are here

function simplenews_node_delete in Simplenews 7

Same name and namespace in other branches
  1. 8.2 simplenews.module \simplenews_node_delete()
  2. 8 simplenews.module \simplenews_node_delete()
  3. 7.2 simplenews.module \simplenews_node_delete()
  4. 3.x simplenews.module \simplenews_node_delete()

Implements hook_node_delete().

File

./simplenews.module, line 495
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_node_delete($node) {
  if (!simplenews_check_node_types($node->type)) {
    return;
  }
  simplenews_newsletter_delete($node);

  // Check if pending emails of this newsletter issue exist and delete these too.
  module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
  $count = simplenews_delete_spool(array(
    'nid' => $node->nid,
  ));
  if ($count) {
    drupal_set_message(t('Newsletter %title was deleted but had @count pending emails. They can no longer be sent.', array(
      '%title' => $node->title,
      '@count' => $count,
    )), 'warning');
    watchdog('simplenews', 'Newsletter %title deleted with @count pending emails. Emails can no longer be sent.', array(
      '%title' => $node->title,
      '@count' => $count,
    ), WATCHDOG_ALERT);
  }
  drupal_set_message(t('Newsletter %title was deleted.', array(
    '%title' => $node->title,
  )));
}