function advuser_advuser_operations in Advanced User 6.3
Same name and namespace in other branches
- 5.2 advuser.module \advuser_advuser_operations()
- 6.2 advuser.module \advuser_advuser_operations()
- 7.3 advuser.module \advuser_advuser_operations()
Implement a hook_advuser_operations function.
File
- ./
advuser.module, line 211 - Advanced user module allows you to select users based on an advanced set of filtering and apply actions to block, unblock, delete or email the selected users.
Code
function advuser_advuser_operations($form_state = array()) {
$operations = array(
'saveselect' => array(
'label' => t('Save selection criteria'),
),
'selectall' => array(
'label' => t('Select all filtered users'),
),
'deselectall' => array(
'label' => t('Deselect all users'),
),
'email' => array(
'label' => t('Email selected users'),
),
'block' => array(
'label' => t('Block the selected users'),
),
'unblock' => array(
'label' => t('Unblock the selected users'),
),
'delete' => array(
'label' => t('Delete the selected users'),
),
);
// Copied directly from user.module user_user_operations.
if (user_access('administer permissions')) {
$roles = user_roles(TRUE);
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 (!empty($form_state['submitted'])) {
$operation_rid = explode('-', $form_state['values']['operation']);
$operation = $operation_rid[0];
if ($operation == 'add_role' || $operation == 'remove_role') {
$rid = $operation_rid[1];
if (user_access('administer permissions')) {
$operations[$form_state['values']['operation']] = array(
'callback' => 'advuser_multiple_role_edit',
'callback arguments' => array(
$operation,
$rid,
),
);
}
else {
watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
return;
}
}
}
return $operations;
}