function administerusersbyrole_form_user_multiple_cancel_confirm_alter in Administer Users by Role 7.2
Same name and namespace in other branches
- 7 administerusersbyrole.module \administerusersbyrole_form_user_multiple_cancel_confirm_alter()
Implements hook_form_FORM_ID_alter().
Check for cancel permissions. The access control for the people admin page restricts the roles to those which we have _edit_ access rather than cancel access.
File
- ./
administerusersbyrole.module, line 183 - 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 ($form_state['input']['accounts'] as $uid) {
$account = user_load($uid);
// This form bypasses checks and restrictions present when cancelling the user's own account,
// so just check our own permissions.
if (_administerusersbyrole_check_access($account, 'cancel')) {
$anyallowed = TRUE;
}
else {
drupal_set_message(t('You do not have permission to cancel %user.', array(
'%user' => $account->name,
)), 'error');
unset($form_state['input']['accounts'][$uid]);
unset($form['accounts'][$uid]);
}
}
if (!$anyallowed) {
drupal_goto(drupal_substr($form['#action'], 1));
}
}