You are here

function session_limit_user_settings in Session Limit 7.2

Same name and namespace in other branches
  1. 6.2 session_limit.module \session_limit_user_settings()
  2. 6 session_limit.module \session_limit_user_settings()

Session limit user settings form.

1 string reference to 'session_limit_user_settings'
session_limit_menu in ./session_limit.module
Implements hook_menu().

File

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

Code

function session_limit_user_settings($form, $form_state, $account) {
  $form['account'] = array(
    '#type' => 'value',
    '#value' => $account,
  );
  $form['session_limit'] = array(
    '#type' => 'select',
    '#title' => t('Maximum sessions'),
    '#description' => t('Total number simultaneous active sessions this user may have at one time. The default defers to the limits that apply to each of the user\'s roles.'),
    '#required' => FALSE,
    '#default_value' => empty($account->data['session_limit']) ? 0 : $account->data['session_limit'],
    '#options' => _session_limit_user_options(),
  );
  if ($account->uid == 1) {
    $form['session_limit']['#states'] = array(
      'enabled' => array(
        ':input[name="session_limit_include_root_user"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $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),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}