You are here

function session_limit_settings in Session Limit 7.2

Same name and namespace in other branches
  1. 5 session_limit.module \session_limit_settings()
  2. 6.2 session_limit.module \session_limit_settings()
  3. 6 session_limit.module \session_limit_settings()
1 string reference to 'session_limit_settings'
session_limit_menu in ./session_limit.module
Implements hook_menu().

File

./session_limit.module, line 125
Limits multiple sessions per user.

Code

function session_limit_settings() {
  $form['session_limit_max'] = array(
    '#type' => 'textfield',
    '#title' => t('Default maximum number of active sessions'),
    '#default_value' => variable_get('session_limit_max', 1),
    '#size' => 2,
    '#maxlength' => 3,
    '#description' => t('The maximum number of active sessions a user can have. 0 implies unlimited sessions.'),
  );
  $form['session_limit_include_root_user'] = array(
    '#type' => 'checkbox',
    '#title' => t('Apply limit to root admin user.'),
    '#description' => t('By default session limits do not apply to user #1'),
    '#default_value' => variable_get('session_limit_include_root_user', FALSE),
  );
  $limit_behaviours = array(
    SESSION_LIMIT_DO_NOTHING => t('Do nothing.'),
    SESSION_LIMIT_DROP => t('Automatically drop the oldest sessions without prompting.'),
    SESSION_LIMIT_DISALLOW_NEW => t('Prevent new session.'),
  );
  $form['session_limit_behaviour'] = array(
    '#type' => 'radios',
    '#title' => t('When the session limit is exceeded'),
    '#default_value' => variable_get('session_limit_behaviour', SESSION_LIMIT_DO_NOTHING),
    '#options' => $limit_behaviours,
  );
  if (module_exists('masquerade')) {
    $form['session_limit_masquerade_ignore'] = array(
      '#type' => 'checkbox',
      '#title' => t('Ignore masqueraded sessions.'),
      '#description' => t("When a user administrator uses the masquerade module to impersonate a different user, it won't count against the session limit counter"),
      '#default_value' => variable_get('session_limit_masquerade_ignore', FALSE),
    );
  }
  $form['session_limit_limit_hit_message'] = array(
    '#type' => 'textarea',
    '#title' => t('Session limit has been hit message'),
    '#default_value' => variable_get('session_limit_limit_hit_message', SESSION_LIMIT_HIT_MESSAGE),
    '#description' => t('The message that is displayed to a user on the current workstation if the session limit has been reached.<br />
      @number is replaced with the maximum number of simultaneous sessions.'),
  );
  $form['session_limit_logged_out_message_severity'] = array(
    '#type' => 'select',
    '#title' => t('Logged out message severity'),
    '#default_value' => variable_get('session_limit_logged_out_message_severity', SESSION_LIMIT_LOGGED_OUT_MESSAGE_SEVERITY),
    '#options' => array(
      'error' => t('Error'),
      'warning' => t('Warning'),
      'status' => t('Status'),
      '_none' => t('No Message'),
    ),
    '#description' => t('The Drupal message type.  Defaults to Error.'),
  );
  $form['session_limit_logged_out_message'] = array(
    '#type' => 'textarea',
    '#title' => t('Logged out message'),
    '#default_value' => variable_get('session_limit_logged_out_message', SESSION_LIMIT_LOGGED_OUT_MESSAGE),
    '#description' => t('The message that is displayed to a user if the workstation has been logged out.<br />
      @number is replaced with the maximum number of simultaneous sessions.'),
  );
  return system_settings_form($form);
}