function user_admin_roles

Form to re-order roles or add a new one.

See also

theme_user_admin_roles()

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 861

Code

function user_admin_roles($form, $form_state) {
    $roles = user_roles();
    $role_weights = db_query('SELECT r.rid, r.weight FROM {role} r')->fetchAllKeyed();
    $form['roles'] = array(
        '#tree' => TRUE,
    );
    foreach ($roles as $rid => $name) {
        $form['roles'][$rid]['#role'] = (object) array(
            'rid' => $rid,
            'name' => $name,
            'weight' => $role_weights[$rid],
        );
        $form['roles'][$rid]['#weight'] = $role_weights[$rid];
        $form['roles'][$rid]['weight'] = array(
            '#type' => 'textfield',
            '#title' => t('Weight for @title', array(
                '@title' => $name,
            )),
            '#title_display' => 'invisible',
            '#size' => 4,
            '#default_value' => $role_weights[$rid],
            '#attributes' => array(
                'class' => array(
                    'role-weight',
                ),
            ),
        );
    }
    $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.