You are here

function adminrole_form_user_admin_settings_alter in Admin role 6

Same name and namespace in other branches
  1. 7 adminrole.module \adminrole_form_user_admin_settings_alter()

Implements hook_form_FORM_ID_alter().

File

./adminrole.module, line 12
This module simply gives a designated role all permissions every time the modules page is submitted.

Code

function adminrole_form_user_admin_settings_alter(&$form, $form_state) {

  // Administrative role option.
  $form['admin_role'] = array(
    '#type' => 'fieldset',
    '#title' => t('Administrator role'),
  );

  // Do not allow users to set the anonymous or authenticated user roles as the
  // administrator role.
  $roles = user_roles();
  unset($roles[DRUPAL_ANONYMOUS_RID]);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);
  $form['admin_role']['user_admin_role'] = array(
    '#type' => 'select',
    '#title' => t('Administrator role'),
    '#default_value' => variable_get('user_admin_role', 0),
    '#options' => array(
      0 => t('Disabled'),
    ) + $roles,
    '#description' => t('This role will be automatically assigned new permissions whenever a module is enabled.'),
  );

  // Ensure the save/reset buttons have a lower weight than our fieldset.
  $form['buttons'] += array(
    '#weight' => 100,
  );
}