You are here

function simplenews_subscription_multiple_delete_confirm in Simplenews 5

Same name and namespace in other branches
  1. 6.2 includes/simplenews.admin.inc \simplenews_subscription_multiple_delete_confirm()
  2. 6 simplenews.admin.inc \simplenews_subscription_multiple_delete_confirm()

Delete multiple subscriptions

1 string reference to 'simplenews_subscription_multiple_delete_confirm'
simplenews_menu in ./simplenews.module
Implementation of hook_menu().

File

./simplenews.module, line 2053

Code

function simplenews_subscription_multiple_delete_confirm() {

  // Subscriptions to be deleted are passed via session var.
  $snids = $_SESSION['simplenews_subscriptions_delete'];
  $form['notice'] = array(
    '#value' => t('These user(s) will be unsubscribed from any and all Newsletters to which they are currently subscribed. This will not delete related user account(s) from this site.'),
  );
  $form['snids'] = array(
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );

  // array_filter returns only elements with TRUE values
  foreach (array_filter($snids) as $snid => $value) {
    $mail = db_result(db_query('SELECT mail FROM {simplenews_subscriptions} WHERE snid = %d', $snid));
    $form['snids'][$snid] = array(
      '#type' => 'hidden',
      '#value' => $snid,
      '#prefix' => '<li>',
      '#suffix' => check_plain($mail) . "</li>\n",
    );
  }
  $form['operation'] = array(
    '#type' => 'hidden',
    '#value' => 'delete',
  );
  return confirm_form($form, t('Are you sure you want to delete these subscriptions?'), 'admin/content/newsletters/users', NULL, t('Delete all'), t('Cancel'));
}