You are here

function logintoboggan_main_settings in LoginToboggan 6

Same name and namespace in other branches
  1. 5 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 665
Logintoboggan Module

Code

function logintoboggan_main_settings(&$form_state) {
  $_disabled = t('Disabled');
  $_enabled = t('Enabled');
  $form['login'] = array(
    '#type' => 'fieldset',
    '#title' => t('Login'),
  );
  $form['login']['logintoboggan_login_with_email'] = array(
    '#type' => 'radios',
    '#title' => t('Allow users to login using their e-mail address'),
    '#default_value' => variable_get('logintoboggan_login_with_email', 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']['logintoboggan_confirm_email_at_registration'] = array(
    '#type' => 'radios',
    '#title' => t('Use two e-mail fields on registration form'),
    '#default_value' => variable_get('logintoboggan_confirm_email_at_registration', 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 <a href=\"!help\">LoginToboggan help</a>.", array(
      '!help' => url('admin/help/logintoboggan'),
    ));
  }
  else {
    $help_text = '';
  }
  $form['registration']['user_email_verification'] = array(
    '#type' => 'checkbox',
    '#title' => t('Set password'),
    '#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 <a href=\"!settings\">Require e-mail verification when a visitor creates an account</a> setting, and is merely here for convenience). If selected, users will be assigned to the role below. 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 <a href=\"!settings\">Welcome, no approval required</a> text.", array(
      '!settings' => url('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']['logintoboggan_pre_auth_role'] = array(
    '#type' => 'select',
    '#title' => t('Non-authenticated role'),
    '#options' => $roles,
    '#default_value' => variable_get('logintoboggan_pre_auth_role', DRUPAL_AUTHENTICATED_RID),
    '#description' => t('If "Set password" 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>. <strong>WARNING: changing this setting after initial site setup can cause undesirable results, including unintended deletion of users -- change with extreme caution!</strong>', array(
      '!url' => url('admin/user/roles'),
    )),
  );
  $purge_options = array(
    0 => t('Never delete'),
    86400 => t('1 Day'),
    172800 => t('2 Days'),
    259200 => t('3 Days'),
    345600 => t('4 Days'),
    432000 => t('5 Days'),
    518400 => t('6 Days'),
    604800 => t('1 Week'),
    1209600 => t('2 Weeks'),
    2592000 => t('1 Month'),
    7776000 => t('3 Months'),
    15379200 => t('6 Months'),
    30758400 => t('1 Year'),
  );
  $form['registration']['logintoboggan_purge_unvalidated_user_interval'] = array(
    '#type' => 'select',
    '#title' => t('Delete unvalidated users after'),
    '#options' => $purge_options,
    '#default_value' => variable_get('logintoboggan_purge_unvalidated_user_interval', 0),
    '#description' => t("If enabled, users that are still in the 'Non-authenticated role' set above will be deleted automatically from the system, if the set time interval since their initial account creation has passed. This can be used to automatically purge spambot registrations. Note: this requires cron, and also requires that the 'Set password' option above is enabled. <strong>WARNING: changing this setting after initial site setup can cause undesirable results, including unintended deletion of users -- change with extreme caution! (please read the CAVEATS section of INSTALL.txt for important information on configuring this feature)</strong>"),
  );
  $form['registration']['logintoboggan_immediate_login_on_register'] = array(
    '#type' => 'checkbox',
    '#title' => t('Immediate login'),
    '#default_value' => variable_get('logintoboggan_immediate_login_on_register', TRUE),
    '#description' => t("If set, the user will be logged in immediately after registering. Note this only applies if the 'Set password' option above is enabled."),
  );
  $form['registration']['redirect'] = array(
    '#type' => 'fieldset',
    '#title' => t('Redirections'),
    '#collapsible' => true,
    '#collapsed' => false,
  );
  $form['registration']['redirect']['logintoboggan_redirect_on_register'] = array(
    '#type' => 'textfield',
    '#title' => t('Redirect path on registration'),
    '#default_value' => variable_get('logintoboggan_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']['logintoboggan_redirect_on_confirm'] = array(
    '#type' => 'textfield',
    '#title' => t('Redirect path on confirmation'),
    '#default_value' => variable_get('logintoboggan_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. In the case where users are not creating their own passwords, it is suggested to use <cite>user/%uid/edit</cite> here, so the user may set their password immediately after validating their account.'),
  );
  $form['registration']['redirect']['logintoboggan_override_destination_parameter'] = array(
    '#type' => 'checkbox',
    '#title' => t('Override destination parameter'),
    '#default_value' => variable_get('logintoboggan_override_destination_parameter', 1),
    '#description' => t("Normally, when a Drupal redirect is performed, priority is given to the 'destination' parameter from the originating URL. With this setting enabled, LoginToboggan will attempt to override this behavior with any values set above."),
  );
  $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']['logintoboggan_login_successful_message'] = array(
    '#type' => 'radios',
    '#title' => t('Display login successful message'),
    '#options' => array(
      $_disabled,
      $_enabled,
    ),
    '#default_value' => variable_get('logintoboggan_login_successful_message', 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']['logintoboggan_minimum_password_length'] = array(
    '#type' => 'select',
    '#title' => t('Minimum password length'),
    '#options' => $min_pass_options,
    '#default_value' => variable_get('logintoboggan_minimum_password_length', 0),
    '#description' => t('LoginToboggan automatically performs basic password validation for illegal characters. If you would additionally like to have a minimum password length requirement, select the length here, or set to \'None\' for no password length validation.'),
  );
  return system_settings_form($form);
}