You are here

function userone_admin_settings in User One 7

Same name and namespace in other branches
  1. 6 userone.module \userone_admin_settings()
1 string reference to 'userone_admin_settings'
userone_menu in ./userone.module
Implements hook_menu().

File

./userone.module, line 93
User One module.

Code

function userone_admin_settings() {

  // Since select values are string, resave them as integer.
  foreach (array(
    'ip_limit' => 50,
    'ip_window' => 3600,
    'user_limit' => 5,
    'user_window' => 21600,
  ) as $param => $default) {
    if (is_string($val = variable_get("user_failed_login_{$param}", $default))) {
      variable_set("user_failed_login_{$param}", (int) $val);
    }
  }
  $form['userone_edit_access_info'] = array(
    '#type' => 'item',
    '#title' => t('Access to user one edit blocked'),
    '#markup' => t('No account except user one account can edit user one account.'),
  );
  $form['userone_view_access_info'] = array(
    '#type' => 'item',
    '#title' => t('Access to user one profile blocked'),
    '#markup' => t('No account except user one account can view user one account.'),
  );
  $form['failed_login'] = array(
    '#type' => 'fieldset',
    '#title' => 'Allowed failed login attempts',
    '#description' => "This setting exposes Drupal's built-in configuration values otherwise inaccessible. It applies to all users, not just user one.",
  );
  $form['failed_login']['user_failed_login_ip_limit'] = array(
    '#type' => 'select',
    '#title' => t('Allowed failed login attempts for an IP address (default 50)'),
    '#options' => array(
      1 => 1,
      2 => 2,
      3 => 3,
      4 => 4,
      5 => 5,
      10 => 10,
      25 => 25,
      50 => 50,
      75 => 75,
      100 => 100,
      250 => 250,
    ),
    '#default_value' => variable_get('user_failed_login_ip_limit', 50),
    '#description' => t("Do not allow any login from the current user's IP if the limit has been reached. Default is 50 failed attempts allowed in one hour. This is independent of the per-user limit to catch attempts from one IP to log in to many different user accounts.  We have a reasonably high limit since there may be only one apparent IP for all users at an institution."),
  );
  $form['failed_login']['user_failed_login_ip_window'] = array(
    '#type' => 'select',
    '#title' => t('Failed login window for an IP address (default 1 hour)'),
    '#options' => array(
      300 => '5 minutes',
      600 => '10 minutes',
      900 => '15 minutes',
      1800 => '30 minutes',
      2700 => '45 minutes',
      3600 => '1 hour',
      7200 => '2 hours',
      10800 => '3 hours',
      14400 => '4 hours',
      18000 => '5 hours',
      21600 => '6 hours',
      28800 => '8 hours',
      36000 => '10 hours',
      43200 => '12 hours',
      86400 => '24 hours',
    ),
    '#default_value' => variable_get('user_failed_login_ip_window', 3600),
    '#description' => t('Time period during which failed logins are accounted for.'),
  );
  $form['failed_login']['userone_block_ip_on_failed_login_ip'] = array(
    '#type' => 'checkbox',
    '#title' => t('Permanently block IP when failed logins breaks threshold') . ' (' . l(t('See blocked IPs'), 'admin/config/people/ip-blocking') . ')',
    '#default_value' => variable_get('userone_block_ip_on_failed_login_ip', FALSE),
    '#description' => 'User one account will be notified when an IP is blocked.',
  );
  $form['failed_login']['divider'] = array(
    '#type' => 'item',
    '#markup' => '<hr style="width: 50%" />',
  );
  $form['failed_login']['user_failed_login_user_limit'] = array(
    '#type' => 'select',
    '#title' => t('Allowed failed login attempts for an account (default 5)'),
    '#options' => array(
      1 => 1,
      2 => 2,
      3 => 3,
      4 => 4,
      5 => 5,
      10 => 10,
      25 => 25,
      50 => 50,
      75 => 75,
      100 => 100,
      250 => 250,
    ),
    '#default_value' => variable_get('user_failed_login_user_limit', 5),
    '#description' => t('User will be allowed to attempt logins this many times within the period (see below).'),
  );
  $form['failed_login']['user_failed_login_user_window'] = array(
    '#type' => 'select',
    '#title' => t('Failed login window for an account (default 6 hours)'),
    '#options' => array(
      300 => '5 minutes',
      600 => '10 minutes',
      900 => '15 minutes',
      1800 => '30 minutes',
      2700 => '45 minutes',
      3600 => '1 hour',
      7200 => '2 hours',
      10800 => '3 hours',
      14400 => '4 hours',
      18000 => '5 hours',
      21600 => '6 hours',
      28800 => '8 hours',
      36000 => '10 hours',
      43200 => '12 hours',
      86400 => '24 hours',
    ),
    '#default_value' => variable_get('user_failed_login_user_window', 21600),
    '#description' => t('Number of failed logins for an account will be accounted for this period'),
  );
  $form['failed_login']['userone_block_ip_on_failed_login_user1'] = array(
    '#type' => 'checkbox',
    '#title' => t('Permanently block IP when failed logins <strong>for user one</strong> breaks threshold') . ' (' . l(t('See blocked IPs'), 'admin/config/people/ip-blocking') . ')',
    '#default_value' => variable_get('userone_block_ip_on_failed_login_user1', FALSE),
    '#description' => 'User one account will be notified when an IP is blocked.',
  );
  return system_settings_form($form);
}