You are here

function masquerade_admin_settings in Masquerade 7

Same name and namespace in other branches
  1. 6 masquerade.module \masquerade_admin_settings()

Admin settings form.

1 string reference to 'masquerade_admin_settings'
masquerade_menu in ./masquerade.module
Implements hook_menu().

File

./masquerade.module, line 261
The masquerade module allows administrators to masquerade as other user.

Code

function masquerade_admin_settings() {

  // create a list of roles; all selected roles are considered administrative.
  $roles = user_roles();
  $form['masquerade_admin_roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles that are considered "administrators" for masquerading'),
    '#options' => $roles,
    '#default_value' => variable_get('masquerade_admin_roles', array()),
  );
  $test_name = _masquerade_user_load(variable_get('masquerade_test_user', ''));
  $form['masquerade_test_user'] = array(
    '#type' => 'textfield',
    '#title' => t('Menu <em>Quick Switch</em> user'),
    '#autocomplete_path' => 'masquerade/autocomplete',
    '#default_value' => isset($test_name->name) ? check_plain($test_name->name) : '',
    '#description' => t('Enter the username of an account you wish to switch easily between via a menu item.'),
    '#maxlength' => NULL,
  );
  $quick_switch = user_load_multiple(variable_get('masquerade_quick_switches', array()));
  $quick_switch_users = array();
  foreach ($quick_switch as $uid => $account) {
    if ($uid == 0) {
      $account->name = variable_get('anonymous', t('Anonymous'));
    }
    $quick_switch_users[] = $account->name;
  }
  $form['masquerade_quick_switches'] = array(
    '#type' => 'textfield',
    '#title' => t('Masquerade Block <em>Quick Switch</em> users'),
    '#autocomplete_path' => 'masquerade/autocomplete-users',
    '#default_value' => drupal_implode_tags($quick_switch_users),
    '#description' => t('Enter the usernames, separated by commas, of accounts to show as quick switch links in the Masquerade block.'),
    '#maxlength' => NULL,
  );
  $form = system_settings_form($form);
  $form['#validate'][] = 'masquerade_admin_settings_validate';
  $form['#submit'][] = 'masquerade_admin_settings_submit';
  return $form;
}