function role_delegation_form_user_admin_account_alter in Role Delegation 7
Implements hook_form_FORM_ID_alter() for user_admin_account().
In the user bulk update form, separates out the role delegation operations and groups and relabels them under 'Add a role' and 'Remove a role' optgroups.
File
- ./
role_delegation.module, line 298 - This module allows site administrators to grant some roles the authority to change roles assigned to users, without them needing the 'administer access control' permission.
Code
function role_delegation_form_user_admin_account_alter(&$form, $form_state, $form_id) {
if (!isset($form['options']['operation']['#options'])) {
return;
}
$options = $form['options']['operation']['#options'];
$roles = _role_delegation_roles();
$add_roles = array();
$remove_roles = array();
foreach ($options as $option => $label) {
$operation_rid = explode('-', $option);
$operation = $operation_rid[0];
if ($operation == 'role_delegation_add_role') {
$rid = $operation_rid[1];
$add_roles[$option] = $roles[$rid];
unset($options[$option]);
}
elseif ($operation == 'role_delegation_remove_role') {
$rid = $operation_rid[1];
$remove_roles[$option] = $roles[$rid];
unset($options[$option]);
}
}
if (count($add_roles)) {
$form['options']['operation']['#options'] = $options + array(
t('Add a role to the selected users') => $add_roles,
t('Remove a role from the selected users') => $remove_roles,
);
}
}