You are here

function advuser_multiple_delete_confirm in Advanced User 6.3

Same name and namespace in other branches
  1. 5.2 advuser.module \advuser_multiple_delete_confirm()
  2. 6.2 advuser.module \advuser_multiple_delete_confirm()
  3. 7.3 forms/advuser_multiple_delete_confirm.inc \advuser_multiple_delete_confirm()

Implement the menu callback function for admin/user/user/advuser/confirm/delete.

1 string reference to 'advuser_multiple_delete_confirm'
advuser_menu in ./advuser.module
Implementation of hook_menu().

File

forms/advuser_multiple_delete_confirm.inc, line 13
Confirm the delete of selected users.

Code

function advuser_multiple_delete_confirm() {
  $advuser =& $_SESSION['advuser'];
  $accounts =& $advuser['accounts'];
  $selectall =& $advuser['selectall'];
  $deselected =& $advuser['deselected'];
  $form['accounts'] = array(
    '#type' => 'fieldset',
    '#title' => t('Selected users'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );
  if ($selectall) {
    $sql = advuser_build_query('name');
    $filter = advuser_build_filter_query();
    $result = db_query($sql, $filter['args']);
    while ($account = db_fetch_object($result)) {
      if (!isset($deselected[$account->uid])) {
        $accounts[$account->uid] = $account->uid;
        $form['accounts'][$account->uid] = array(
          '#type' => 'markup',
          '#value' => check_plain($account->name),
          '#prefix' => '<li>',
          '#suffix' => '</li>',
        );
      }
    }
  }
  else {

    // array_filter returns only elements with TRUE values
    foreach (array_filter($accounts) as $uid => $value) {
      $user = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid));
      $form['accounts'][$uid] = array(
        '#type' => 'markup',
        '#value' => check_plain($user),
        '#prefix' => '<li>',
        '#suffix' => "</li>",
      );
    }
  }
  $form['operation'] = array(
    '#type' => 'hidden',
    '#value' => 'delete',
  );
  return confirm_form($form, t('Are you sure you want to delete these users?'), 'admin/user/user/advuser', t('This action cannot be undone.'), t('Delete all'), t('Cancel'));
}