function user_user_operations in Drupal 5
Same name and namespace in other branches
- 6 modules/user/user.module \user_user_operations()
- 7 modules/user/user.module \user_user_operations()
Implementation of hook_user_operations().
File
- modules/
user/ user.module, line 2177 - Enables the user registration and login system.
Code
function user_user_operations() {
global $form_values;
$operations = array(
'unblock' => array(
'label' => t('Unblock the selected users'),
'callback' => 'user_user_operations_unblock',
),
'block' => array(
'label' => t('Block the selected users'),
'callback' => 'user_user_operations_block',
),
'delete' => array(
'label' => t('Delete the selected users'),
),
);
if (user_access('administer access control')) {
$roles = user_roles(1);
unset($roles[DRUPAL_AUTHENTICATED_RID]);
// Can't edit authenticated role.
$add_roles = array();
foreach ($roles as $key => $value) {
$add_roles['add_role-' . $key] = $value;
}
$remove_roles = array();
foreach ($roles as $key => $value) {
$remove_roles['remove_role-' . $key] = $value;
}
if (count($roles)) {
$role_operations = array(
t('Add a role to the selected users') => array(
'label' => $add_roles,
),
t('Remove a role from the selected users') => array(
'label' => $remove_roles,
),
);
$operations += $role_operations;
}
}
// If the form has been posted, we need to insert the proper data for role editing if necessary.
if ($form_values) {
$operation_rid = explode('-', $form_values['operation']);
$operation = $operation_rid[0];
$rid = $operation_rid[1];
if ($operation == 'add_role' || $operation == 'remove_role') {
if (user_access('administer access control')) {
$operations[$form_values['operation']] = array(
'callback' => 'user_multiple_role_edit',
'callback arguments' => array(
$operation,
$rid,
),
);
}
else {
watchdog('security', t('Detected malicious attempt to alter protected user fields.'), WATCHDOG_WARNING);
return;
}
}
}
return $operations;
}