You are here

function adminrole_form_alter in Admin role 5

Same name and namespace in other branches
  1. 6 adminrole.module \adminrole_form_alter()
  2. 7 adminrole.module \adminrole_form_alter()

Implement hook_form_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_alter($form_id, &$form) {
  if ($form_id == 'user_admin_settings') {

    // 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,
    );
  }
  if (in_array($form_id, array(
    'system_modules',
    'user_admin_settings',
    'cck_field_perms_admin_settings_form',
  ))) {
    $form['#submit']['adminrole_update_permissions'] = array();
  }
}