You are here

function logintoboggan_main_settings in LoginToboggan 5

Same name and namespace in other branches
  1. 6 logintoboggan.module \logintoboggan_main_settings()
  2. 7 logintoboggan.admin.inc \logintoboggan_main_settings()
2 string references to 'logintoboggan_main_settings'
logintoboggan_form_alter in ./logintoboggan.module
Implementation of hook_form_alter()
logintoboggan_menu in ./logintoboggan.module
Implementation of hook_menu()

File

./logintoboggan.module, line 609
Logintoboggan Module

Code

function logintoboggan_main_settings() {
  $_disabled = t('disabled');
  $_enabled = t('enabled');
  $form['login'] = array(
    '#type' => 'fieldset',
    '#title' => t('Login'),
  );
  $form['login']['login_with_mail'] = array(
    '#type' => 'radios',
    '#title' => t('Allow users to login using their e-mail address'),
    '#default_value' => variable_get('login_with_mail', 0),
    '#options' => array(
      $_disabled,
      $_enabled,
    ),
    '#description' => t('Users will be able to enter EITHER their username OR their e-mail address to log in.'),
  );
  $form['registration'] = array(
    '#type' => 'fieldset',
    '#title' => t('Registration'),
  );
  $form['registration']['email_reg_confirm'] = array(
    '#type' => 'radios',
    '#title' => t('Use two e-mail fields on registration form'),
    '#default_value' => variable_get('email_reg_confirm', 0),
    '#options' => array(
      $_disabled,
      $_enabled,
    ),
    '#description' => t('User will have to type the same e-mail address into both fields. This helps to confirm that they\'ve typed the correct address.'),
  );
  if (module_exists('help')) {
    $help_text = t(" More help in writing the e-mail message can be found at !help.", array(
      '!help' => l('LoginToboggan help', 'admin/help/logintoboggan'),
    ));
  }
  else {
    $help_text = '';
  }
  $form['registration']['user_email_verification'] = array(
    '#type' => 'checkbox',
    '#title' => t('Set password & Immediate login'),
    '#default_value' => !variable_get('user_email_verification', TRUE) ? 1 : 0,
    '#description' => t('This will allow users to choose their initial password when registering (note that this setting is merely a mirror of the !email_verification setting, and is merely here for convenience).  If \'Set password & Immediate login\' is selected, users will be assigned to the role below and logged in immediately. They will not be assigned to the "authenticated user" role until they confirm their e-mail address by following the link in their registration e-mail. It is HIGHLY recommended that you set up a "pre-authorized" role with limited permissions for this purpose. <br />NOTE: If you enable this feature, you should edit the !settings.', array(
      '!email_verification' => l('Require e-mail verification when a visitor creates an account', 'admin/user/settings'),
      '!settings' => l('user e-mail welcome message', 'admin/user/settings'),
    )) . $help_text,
  );

  // Grab the roles that can be used for pre-auth.  Remove the anon role, as it's not a valid choice.
  $roles = user_roles(1);
  $form['registration']['toboggan_role'] = array(
    '#type' => 'select',
    '#title' => t('Non-authenticated role'),
    '#options' => $roles,
    '#default_value' => variable_get('toboggan_role', DRUPAL_AUTHENTICATED_RID),
    '#description' => t('If "Set password & Immediate login" is selected, users will be able to login before their e-mail address has been authenticated. Therefore, you must choose a role for new non-authenticated users. Users will be removed from this role and assigned to the "authenticated user" role once they follow the link in their welcome e-mail. <a href="!url">Add new roles</a>.', array(
      '!url' => url('admin/user/roles'),
    )),
  );
  $form['registration']['redirect'] = array(
    '#type' => 'fieldset',
    '#title' => t('Redirections'),
    '#collapsible' => true,
    '#collapsed' => false,
  );
  $form['registration']['redirect']['toboggan_redirect_on_register'] = array(
    '#type' => 'textfield',
    '#title' => t('Redirect path on Registration'),
    '#default_value' => variable_get('toboggan_redirect_on_register', ''),
    '#description' => t('Normally, after a user registers a new account, they will be taken to the front page, or to their user page if you specify <cite>Immediate login</cite> above. Leave this setting blank if you wish to keep the default behavior. If you wish the user to go to a page of your choosing, then enter the path for it here. For instance, you may redirect them to a static page such as <cite>node/35</cite>, or to the <cite>&lt;front&gt;</cite> page. You may also use <em>%uid</em> as a variable, and the user\'s user ID will be substituted in the path.'),
  );
  $form['registration']['redirect']['toboggan_redirect_on_confirm'] = array(
    '#type' => 'textfield',
    '#title' => t('Redirect path on Confirmation'),
    '#default_value' => variable_get('toboggan_redirect_on_confirm', ''),
    '#description' => t('Normally, after a user confirms their new account, they will be taken to their user page. Leave this setting blank if you wish to keep the default behavior. If you wish the user to go to a page of your choosing, then enter the path for it here. For instance, you may redirect them to a static page such as <cite>node/35</cite>, or to the <cite>&lt;front&gt;</cite> page. You may also use <em>%uid</em> as a variable, and the user\'s user ID will be substituted in the path.'),
  );
  $form['other'] = array(
    '#type' => 'fieldset',
    '#title' => t('Other'),
    '#tree' => FALSE,
  );
  $site403 = variable_get('site_403', '');
  if ($site403 == 'toboggan/denied') {
    $disabled = '';
  }
  else {
    $disabled = $site403;
  }
  $options = array(
    $disabled => $_disabled,
    'toboggan/denied' => $_enabled,
  );
  $form['other']['site_403'] = array(
    '#type' => 'radios',
    '#title' => t('Present login form on access denied (403)'),
    '#options' => $options,
    '#default_value' => $site403,
    '#description' => t('Anonymous users will be presented with a login form along with an access denied message.'),
  );
  $form['other']['login_successful'] = array(
    '#type' => 'radios',
    '#title' => t('Display login successful message'),
    '#options' => array(
      $_disabled,
      $_enabled,
    ),
    '#default_value' => variable_get('login_successful', 0),
    '#description' => t('If enabled, users will receive a \'Login successful\' message upon login.'),
  );
  $min_pass_options = array(
    t('None'),
  );
  for ($i = 2; $i < 30; $i++) {
    $min_pass_options[$i] = $i;
  }
  $form['other']['toboggan_min_pass_length'] = array(
    '#type' => 'select',
    '#title' => t('Minimum password length'),
    '#options' => $min_pass_options,
    '#default_value' => variable_get('toboggan_min_pass_length', 0),
    '#description' => t('LoginToboggan automatically performs basic password validation for illegal characters. If you would additionally like to have a mimimum password length requirement, select the length here, or set to \'None\' for no password length validation.'),
  );
  return system_settings_form($form);
}