You are here

function masquerade_settings in Masquerade 5

Implementation of hook_settings().

1 string reference to 'masquerade_settings'
masquerade_menu in ./masquerade.module
Implementation of hook_menu().

File

./masquerade.module, line 112
masquerade.module

Code

function masquerade_settings() {

  // create a list of roles; all selected roles are considered administrative.
  $rids = array();
  $result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name");
  while ($obj = db_fetch_object($result)) {
    $rids[$obj->rid] = $obj->name;
  }
  $test_user = user_load(array(
    'name' => variable_get('masquerade_test_user', ''),
  ));
  $quick_switch_users = variable_get('masquerade_quick_switches', array());
  $user_list = db_query_range('SELECT name, uid FROM {users} WHERE uid > 0 ORDER BY name ASC', 0, 1000);
  while ($user_row = db_fetch_array($user_list)) {
    $user_options[$user_row['uid']] = $user_row['name'];
  }
  $form['masquerade_admin_roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t("Roles that are considered 'administrator' for masquerading."),
    '#options' => $rids,
    '#default_value' => variable_get('masquerade_admin_roles', array()),
  );
  $form['masquerade_test_user'] = array(
    '#type' => 'textfield',
    '#title' => t('Default test user'),
    '#autocomplete_path' => 'masquerade/autocomplete',
    '#default_value' => check_plain($test_user->name),
    '#description' => t('Enter the username of an account you wish to switch easily between via a menu item. The name must be an exisiting user.'),
  );
  $form['masquerade_quick_switches'] = array(
    '#type' => 'select',
    '#title' => t('Quick switch users'),
    '#options' => $user_options,
    '#default_value' => $quick_switch_users,
    '#size' => 5,
    '#multiple' => TRUE,
    '#description' => t('Select the usernames for accounts to show as quick links in the Masquerade block.'),
  );
  $form['masquerade_version_information'] = array(
    '#value' => masquerade_version(),
  );
  $form['#validate'] = array(
    'masquerade_settings_validate' => array(),
  );
  return system_settings_form($form);
}