You are here

function user_admin_role in Drupal 6

Same name and namespace in other branches
  1. 4 modules/user.module \user_admin_role()
  2. 5 modules/user/user.module \user_admin_role()
  3. 7 modules/user/user.admin.inc \user_admin_role()

Menu callback: administer roles.

See also

user_admin_role_validate()

user_admin_role_submit()

theme_user_admin_new_role()

Related topics

2 string references to 'user_admin_role'
user_forms in modules/user/user.module
Implementation of hook_forms().
user_menu in modules/user/user.module
Implementation of hook_menu().

File

modules/user/user.admin.inc, line 637
Admin page callback file for the user module.

Code

function user_admin_role() {
  $rid = arg(4);
  if ($rid) {
    if ($rid == DRUPAL_ANONYMOUS_RID || $rid == DRUPAL_AUTHENTICATED_RID) {
      drupal_goto('admin/user/roles');
    }

    // Display the edit role form.
    $role = db_fetch_object(db_query('SELECT * FROM {role} WHERE rid = %d', $rid));
    $form['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Role name'),
      '#default_value' => $role->name,
      '#size' => 30,
      '#required' => TRUE,
      '#maxlength' => 64,
      '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
    );
    $form['rid'] = array(
      '#type' => 'value',
      '#value' => $rid,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save role'),
    );
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete role'),
    );
  }
  else {
    $form['name'] = array(
      '#type' => 'textfield',
      '#size' => 32,
      '#maxlength' => 64,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add role'),
    );
    $form['#submit'][] = 'user_admin_role_submit';
    $form['#validate'][] = 'user_admin_role_validate';
  }
  return $form;
}