You are here

function notifications_multiple_delete_confirm in Notifications 6.4

Same name and namespace in other branches
  1. 6 notifications.manage.inc \notifications_multiple_delete_confirm()
  2. 6.2 notifications.manage.inc \notifications_multiple_delete_confirm()
  3. 6.3 notifications.manage.inc \notifications_multiple_delete_confirm()
  4. 7 notifications.pages.inc \notifications_multiple_delete_confirm()

Form for multiple delete. When account passed check that all subscriptions belong to the user account

5 calls to notifications_multiple_delete_confirm()
notifications_admin_manage_subscriptions in ./notifications.admin.inc
Menu callback: subscriptions administration.
notifications_destination_manage_form in includes/destination.inc
Destination manage subscriptions form
notifications_manage_destination_form in ./notifications.manage.inc
Manage destination form. Edit subscriptions for a destination
notifications_manage_user_subscriptions in ./notifications.manage.inc
Menu callback: user subscriptions management
notifications_subscription_list_form in ./notifications.pages.inc
List form for subscriptions of the same type for a user

File

./notifications.manage.inc, line 386
Common functions for bulk management of subscriptions

Code

function notifications_multiple_delete_confirm(&$form_state, $items, $destination = NULL) {
  $destination = $destination ? $destination : $_GET['q'];
  if (notifications_manage_subscriptions_access(array_keys($items))) {
    $form['items'] = array(
      '#prefix' => '<ul>',
      '#suffix' => '</ul>',
      '#tree' => TRUE,
    );

    // array_filter returns only elements with TRUE values
    foreach ($items as $id => $value) {

      // Load the subscription to display a friendly name
      $subscription = notifications_load_subscription($id);
      $form['items'][$id] = array(
        '#type' => 'hidden',
        '#value' => $id,
        '#prefix' => '<li>',
        '#suffix' => $subscription
          ->format_long() . "</li>\n",
      );
    }
    $form['operation'] = array(
      '#type' => 'hidden',
      '#value' => 'delete',
    );
    $form['#submit'][] = 'notifications_multiple_delete_confirm_submit';
    $form['#validate'][] = 'notifications_multiple_delete_confirm_validate';
    $form['#redirect'] = $destination;
    return confirm_form($form, t('Are you sure you want to delete these items?'), $destination, t('This action cannot be undone.'), t('Delete all'), t('Cancel'));
  }
  else {
    drupal_set_message(t('Validation error. You don\'t have permission to delete some of these subscriptions'), 'error');
    drupal_access_denied();
  }
}