function user_admin_roles in Drupal 7
Form to re-order roles or add a new one.
See also
Related topics
1 string reference to 'user_admin_roles'
- user_menu in modules/
user/ user.module - Implements hook_menu().
File
- modules/
user/ user.admin.inc, line 844 - Admin page callback file for the user module.
Code
function user_admin_roles($form, $form_state) {
$roles = user_roles();
$form['roles'] = array(
'#tree' => TRUE,
);
$order = 0;
foreach ($roles as $rid => $name) {
$form['roles'][$rid]['#role'] = (object) array(
'rid' => $rid,
'name' => $name,
'weight' => $order,
);
$form['roles'][$rid]['#weight'] = $order;
$form['roles'][$rid]['weight'] = array(
'#type' => 'textfield',
'#title' => t('Weight for @title', array(
'@title' => $name,
)),
'#title_display' => 'invisible',
'#size' => 4,
'#default_value' => $order,
'#attributes' => array(
'class' => array(
'role-weight',
),
),
);
$order++;
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#title_display' => 'invisible',
'#size' => 32,
'#maxlength' => 64,
);
$form['add'] = array(
'#type' => 'submit',
'#value' => t('Add role'),
'#validate' => array(
'user_admin_role_validate',
),
'#submit' => array(
'user_admin_role_submit',
),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save order'),
'#submit' => array(
'user_admin_roles_order_submit',
),
);
return $form;
}