You are here

function simplenews_category_delete in Simplenews 7

Delete newsletter category from the database.

Parameters

$category: Simplenews category object or category ID.

Related topics

2 calls to simplenews_category_delete()
simplenews_admin_category_delete_submit in includes/simplenews.admin.inc
Form submit callback for deleting a simplenews category.
simplenews_taxonomy_term_delete in ./simplenews.module
Implements hook_taxonomy_term_delete().

File

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

Code

function simplenews_category_delete($category) {
  if (!is_object($category)) {
    $category = simplenews_category_load($category);
  }
  if ($category) {
    db_delete('simplenews_category')
      ->condition('tid', $category->tid)
      ->execute();

    // Delete subscriptions
    simplenews_subscription_delete(array(
      'tid' => $category->tid,
    ));
    drupal_set_message(t('All subscriptions to newsletter %newsletter have been deleted.', array(
      '%newsletter' => _simplenews_newsletter_name($category),
    )));

    // Delete subscription block
    db_delete('block')
      ->condition('module', 'simplenews')
      ->condition('delta', $category->tid)
      ->execute();
    module_invoke_all('simplenews_category_delete', $category);
  }
}