You are here

function administerusersbyrole_form_user_multiple_cancel_confirm_alter in Administer Users by Role 7

Same name and namespace in other branches
  1. 7.2 administerusersbyrole.module \administerusersbyrole_form_user_multiple_cancel_confirm_alter()

Implements hook_form_FORM_ID_alter().

File

./administerusersbyrole.module, line 122
Provides fine-grained permissions for creating, editing, and deleting users.

Code

function administerusersbyrole_form_user_multiple_cancel_confirm_alter(&$form, &$form_state) {
  $anyallowed = FALSE;
  foreach (array_filter($form_state['post']['accounts']) as $uid => $value) {
    $account = user_load($uid);
    if (_administerusersbyrole_can_cancel_user($account)) {
      $anyallowed = TRUE;
    }
    else {
      drupal_set_message(t('You do not have permission to cancel %user.', array(
        '%user' => $account->name,
      )), 'error');
      unset($form_state['post']['accounts'][$uid]);
      unset($form['accounts'][$uid]);
    }
  }
  if (!$anyallowed) {
    drupal_goto(drupal_substr($form['#action'], 1));
  }
}