You are here

function advuser_admin_account_submit in Advanced User 7.3

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

Submit the user administration update form.

File

forms/advuser_admin_account.inc, line 191
This is the part of the form that provides the actions and the list based on the selected filters.

Code

function advuser_admin_account_submit($form, &$form_state) {
  $operations = module_invoke_all('advuser_operations', $form_state);
  $operations += module_invoke_all('user_operations', $form, $form_state);
  $operation = $operations[$form_state['values']['operation']];
  $destination = $form_state['values']['destination'];

  // Filter out unchecked accounts.
  $accounts_selected = array_filter($form_state['values']['accounts']);
  $form_accounts = $form['accounts']['#options'];
  $advuser =& $_SESSION['advuser'];
  $accounts =& $advuser['accounts'];
  $selectall =& $advuser['selectall'];
  $deselected =& $advuser['deselected'];
  switch ($form_state['values']['operation']) {
    case 'saveselect':
      $completeForm =& $form_state['complete form']['accounts'];
      foreach ($form_accounts as $form_user_id => $value) {
        $selected = isset($completeForm[$form_user_id]['#value']) ? $completeForm[$form_user_id]['#value'] : 0;
        if ($selected) {
          $accounts[$form_user_id] = $form_user_id;
          unset($deselected[$form_user_id]);
        }
        else {
          $deselected[$form_user_id] = $form_user_id;
          unset($accounts[$form_user_id]);
        }
      }
      $selectall = FALSE;
      break;
    case 'deselectall':
      $selectall = FALSE;
      $accounts = array();
      $deselected = array();
      drupal_set_message(t('All selections have been reset.'));
      break;
    case 'selectall':
      $selectall = TRUE;
      $accounts = array();
      $deselected = array();
      drupal_set_message(t('All filtered users have been selected.'));
      break;
    case 'email':

      // Menu callback is provided for mass emailing.
      $completeForm =& $form_state['complete form']['accounts'];
      foreach ($form_accounts as $form_user_id => $value) {
        $selected = isset($completeForm[$form_user_id]['#value']) ? $completeForm[$form_user_id]['#value'] : 0;
        if ($selected) {
          $accounts[$form_user_id] = $form_user_id;
        }
      }
      drupal_goto('admin/people/advuser/confirm/email');
      break;
    case 'delete':

      // Menu callback is provided for mass deleting.
      $completeForm =& $form_state['complete form']['accounts'];
      foreach ($form_accounts as $form_user_id => $value) {
        $selected = isset($completeForm[$form_user_id]['#value']) ? $completeForm[$form_user_id]['#value'] : 0;
        if ($selected) {
          $accounts[$form_user_id] = $form_user_id;
        }
      }
      drupal_goto('admin/people/advuser/confirm/delete');
      break;
  }
  if (!empty($operation['callback']) && ($function = $operation['callback'])) {

    // Add in callback arguments if present.
    if (isset($operation['callback arguments'])) {
      $args = array_merge(array(
        $accounts_selected,
      ), $operation['callback arguments']);
    }
    else {
      $args = array(
        $accounts_selected,
      );
    }
    call_user_func_array($function, $args);
    drupal_set_message(t('The update has been performed.'));
  }
}