You are here

function purge_users_multiple_cancel_confirm_submit in Auto Purge Users 7

Same name and namespace in other branches
  1. 7.2 purge_users.module \purge_users_multiple_cancel_confirm_submit()

Submit handler for mass-account cancellation confirmation form.

See also

purge_users_multiple_cancel_confirm()

purge_users_multiple_cancel_confirm_submit()

1 string reference to 'purge_users_multiple_cancel_confirm_submit'
purge_users_multiple_cancel_confirm in ./purge_users.module
Mass cancel user account confirmation form.

File

./purge_users.module, line 356
Purge users module file.

Code

function purge_users_multiple_cancel_confirm_submit($form, &$form_state) {
  if ($form_state['values']['confirm']) {

    // Initialize a batch operation.
    $batch = array(
      'operations' => array(),
      'finished' => 'purge_users_batch_completed',
      'title' => t('Delete users'),
      'init_message' => t('Delete users operation is starting...'),
      'progress_message' => t('Processed @current out of @total.'),
      'error_message' => t('Delete users operation has encountered an error.'),
    );
    foreach ($form_state['values']['accounts'] as $uid => $value) {

      // Prevent programmatic form submissions from cancelling user 1.
      if ($uid <= 1) {
        continue;
      }
      $method = $form_state['values']['purge_user_cancel_method'];
      $account = user_load($uid);
      $batch['operations'][] = array(
        'purge_users_batch_process',
        array(
          $account,
          $method,
        ),
      );
    }

    // Batch set.
    batch_set($batch);
    batch_process('admin/people/purge-rule');
  }
  $form_state['redirect'] = 'admin/people/purge-rule';
}