? logintoboggan-move-settings-form-264295-4.patch ? logintoboggan-radios-to-checkboxes-264300-2.patch ? logintoboggan-unified-login-264332-1.patch Index: logintoboggan.css =================================================================== RCS file: /cvs/drupal/contributions/modules/logintoboggan/logintoboggan.css,v retrieving revision 1.2 diff -u -p -r1.2 logintoboggan.css --- logintoboggan.css 22 Nov 2007 00:51:45 -0000 1.2 +++ logintoboggan.css 29 May 2008 20:02:57 -0000 @@ -1,3 +1,5 @@ +/* $Id$ */ + div.toboggan-container { text-align: center; } @@ -20,4 +22,32 @@ div.user-login-block { div.user-login-block a { text-align: left; +} + +#toboggan-unified #login-message { + text-align: center; + font-size: 2em; + line-height: 1.2; +} + +#toboggan-unified #login-links { + text-align: center; + font-size: 1.5em; + line-height: 2.7; +} + +#toboggan-unified #login-links a { + padding: .5em; + border: 1px #666 solid; + background-color: #EEE; +} + +#toboggan-unified #login-links a:hover { + background-color: #DDD; +} + +#toboggan-unified #login-links a.lt-active, +#toboggan-unified #login-links a.lt-active:hover { + background-color: #FFF19A; + border: 2px #333 solid; } \ No newline at end of file Index: logintoboggan.module =================================================================== RCS file: /cvs/drupal/contributions/modules/logintoboggan/logintoboggan.module,v retrieving revision 1.131 diff -u -p -r1.131 logintoboggan.module --- logintoboggan.module 9 May 2008 00:34:22 -0000 1.131 +++ logintoboggan.module 29 May 2008 20:02:58 -0000 @@ -67,15 +67,17 @@ function logintoboggan_help($path, $arg)
  • Provide a login form on Access Denied pages for non-logged-in (anonymous) users.
  • The module provides two login block options: One uses JavaScript to display the form within the block immediately upon clicking 'log in'. The other brings the user to a separate page, but returns the user to their original page upon login.
  • Customize the registration form with two e-mail fields to ensure accuracy.
  • -
  • Optionally redirect the user to a specific page when using the 'Immediate login' feature.
  • +
  • Optionally redirect the user to a specific page when using the 'Allow users to login immediately upon registering' feature.
  • Optionally redirect the user to a specific page upon validation of their e-mail address.
  • Optionally display a user message indicating a successful login.
  • +
  • Optionally combine both the login and registration form on one page.
  • +
  • Optionally display an 'I forgot my password' link on the user login form.
  • These features may be turned on or off in the Login Toboggan settings.

    -

    Because this module completely reorients the Drupal login process you will probably want to edit the welcome e-mail on the user settings page. For instance if you have enabled the 'Set password & Immediate Login' option, you probably should not send the user's password out in the welcome e-mail (also note when the 'Set password & Immediate Login' option is enabled, the !login_url becomes a verification url that the user MUST visit in order to enable authenticated status). The following is an example welcome e-mail:

    +

    Because this module completely reorients the Drupal login process you will probably want to edit the welcome e-mail on the user settings page. For instance if you have enabled the 'Allow users to login immediately upon registering' option, you probably should not send the user's password out in the welcome e-mail (also note when the 'Allow users to login immediately upon registering' option is enabled, the !login_url becomes a verification url that the user MUST visit in order to enable authenticated status). The following is an example welcome e-mail:

    ", array('!url' => url('admin/user/logintoboggan'))); $output .= drupal_get_form('logintoboggan_example_help'); - $output .= t("

    Note that if you have set the 'Visitors can create accounts but administrator approval is required' option for account approval, and are also using the 'Set password & Immediate Login' feature of LoginToboggan, the user will immediately receive the permissions of the pre-authorized user role -- you may wish to create a pre-authorized role with the exact same permissions as the anonymous user if you wish the newly created user to only have anonymous permissions.

    In order for a site administrator to unblock a user who is awaiting administrator approval, they must either click on the validation link they receive in their notification e-mail, or manually remove the user from the site's pre-authorized role -- afterwards the user will then receive 'authenticated user' permissions. In either case, the user will receive an account activated e-mail if it's enabled on the user settings page -- it's recommended that you edit the default text of the activation e-mail to match LoginToboggan's workflow as described.

    If you are using the 'Visitors can create accounts and no administrator approval is required' option, removal of the pre-authorized role will happen automatically when the user validates their account via e-mail.

    Also be aware that LoginToboggan only affects registrations initiated by users--any user account created by an administrator will not use any LoginToboggan functionality."); + $output .= t("

    Note that if you have set the 'Visitors can create accounts but administrator approval is required' option for account approval, and are also using the 'Allow users to login immediately upon registering' feature of LoginToboggan, the user will immediately receive the permissions of the pre-authorized user role -- you may wish to create a pre-authorized role with the exact same permissions as the anonymous user if you wish the newly created user to only have anonymous permissions.

    In order for a site administrator to unblock a user who is awaiting administrator approval, they must either click on the validation link they receive in their notification e-mail, or manually remove the user from the site's pre-authorized role -- afterwards the user will then receive 'authenticated user' permissions. In either case, the user will receive an account activated e-mail if it's enabled on the user settings page -- it's recommended that you edit the default text of the activation e-mail to match LoginToboggan's workflow as described.

    If you are using the 'Visitors can create accounts and no administrator approval is required' option, removal of the pre-authorized role will happen automatically when the user validates their account via e-mail.

    Also be aware that LoginToboggan only affects registrations initiated by users--any user account created by an administrator will not use any LoginToboggan functionality."); return $output; break; case 'admin/user/logintoboggan': @@ -155,13 +157,18 @@ function logintoboggan_form_alter(&$form // Messages aren't necessary if pre-auth role is authenticated user. if ($in_pre_auth_role && user_access('administer users') && $id != DRUPAL_AUTHENTICATED_RID) { if ((variable_get('user_register', 1) == 2)) { - $form['account']['status']['#description'] = t('If this user was created using the "Immediate Login" feature of LoginToboggan, and they are also awaiting adminstrator approval on their account, you must remove them from the site\'s pre-authorized role in the "Roles" section below, or they will not receive authenticated user permissions!'); + $form['account']['status']['#description'] = t('If this user was created using the "Allow users to login immediately upon registering" feature of LoginToboggan, and they are also awaiting adminstrator approval on their account, you must remove them from the site\'s pre-authorized role in the "Roles" section below, or they will not receive authenticated user permissions!'); } $form['account']['roles']['#description'] = t("The user is assigned LoginToboggan's pre-authorized role, and is not currently receiving authenticated user permissions."); } break; case 'user_login': + if (variable_get('logintoboggan_forgot_pass_link', 0) || variable_get('logintoboggan_unified_login', 0)) { + $form['lost_password'] = array( + '#value' => '

    ' . l(t('I forgot my password'), 'user/password') . '
    ', + ); + } case 'user_login_block': // Grab the message from settings for display at the top of the login block. if ($login_msg = variable_get('logintoboggan_login_block_message', '')) { @@ -489,6 +496,80 @@ function logintoboggan_menu() { } /** + * Implementation of hook_menu_alter(). + */ +function logintoboggan_menu_alter(&$callbacks) { + if (variable_get('logintoboggan_unified_login', 0)) { + // Kill the tabs on the login pages. + $callbacks['user/register']['type'] = MENU_CALLBACK; + $callbacks['user/register']['page callback'] = 'logintoboggan_unified_login_page'; + $callbacks['user/register']['page arguments'] = array('register'); + $callbacks['user/login']['page callback'] = 'logintoboggan_unified_login_page'; + $callbacks['user/password']['type'] = MENU_CALLBACK; + $callbacks['user']['page callback'] = 'logintoboggan_unified_login_page'; + } +} + +/** + * Menu callback for user/login + * creates a unified login/registration form (without tabs) + */ +function logintoboggan_unified_login_page($active_form = 'login') { + global $user; + if ($user->uid) { + menu_set_active_item('user/'. $user->uid); + return menu_execute_active_handler(); + } + else { + $login_form = drupal_get_form('user_login'); + $register_form = drupal_get_form('user_register'); + // TODO: Somehow add a class of "default" to whichever form is the default. + // Then, in the JS, remove hard-coding of hiding the register form, and instead + // hide the one not marked 'default' + $output = theme('lt_unified_login_page', $login_form, $register_form, $active_form); + + return $output; + } +} + +/** + * Theme function for unified login page. + * + * @ingroup themable + */ +function theme_lt_unified_login_page($login_form, $register_form, $active_form) { + // Add some JS and CSS loveliness. + $path = drupal_get_path('module', 'logintoboggan'); + drupal_add_css($path . '/logintoboggan.css'); + drupal_add_js(array('lt' => array('activeForm' => $active_form)), 'setting'); + drupal_add_js($path . '/unifiedlogin.js'); + drupal_set_title(''); + $output = ''; + + $output .= '
    '; + + // Create the initial message and links that people can click on. + $output .= '
    ' . t('You are not logged in.') . '
    '; + $output .= ''; + + // Add the login and registration forms in. + $output .= '
    '; + $output .= $login_form; + $output .= '
    '; + $output .= '
    ' . $register_form . '
    '; + + $output .= '
    '; + + return $output; +} + +/** * Access check for user revalidation. */ function logintoboggan_revalidate_access($uid) { @@ -525,6 +606,9 @@ function logintoboggan_theme() { 'lt_login_link' => array( 'arguments' => array(), ), + 'lt_unified_login_page' => array( + 'arguments' => array('login_form' => NULL, 'register_form' => NULL), + ), ); } @@ -600,9 +684,6 @@ function _logintoboggan_toggleboggan ($f function logintoboggan_main_settings(&$form_state) { $version = str_replace(array('$Re'.'vision:', '$Da'.'te:', '$'), array('', '', ''), '

    Login Toboggan version: $Revision: 1.131 $, $Date: 2008/05/09 00:34:22 $

    '); - $_disabled = t('disabled'); - $_enabled = t('enabled'); - $form['login'] = array( '#type' => 'fieldset', '#title' => t('Login'), @@ -610,29 +691,43 @@ function logintoboggan_main_settings(&$f ); $form['login']['logintoboggan_login_with_email'] = array( - '#type' => 'radios', + '#type' => 'checkbox', '#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['login']['logintoboggan_unified_login'] = array( + '#type' => 'radios', + '#title' => t('Present a unified login and registration page'), + '#default_value' => variable_get('logintoboggan_unified_login', 0), + '#options' => array($_disabled, $_enabled), + '#description' => t("Use one page for both login and register instead of Drupal's tabbed login/registration/password pages."), + ); + + $form['login']['logintoboggan_forgot_pass_link'] = array( + '#type' => 'radios', + '#title' => t('Show a "forgot password" link on the login form'), + '#default_value' => variable_get('logintoboggan_forgot_pass_link', 0), + '#options' => array($_disabled, $_enabled), + '#description' => t("Display a link on the user login form that allows a user to request their password. If the unified login option is enabled, this will automatically be enabled as well."), + ); + $form['registration'] = array( '#type' => 'fieldset', '#title' => t('Registration'), ); $form['registration']['logintoboggan_confirm_email_at_registration'] = array( - '#type' => 'radios', + '#type' => 'checkbox', '#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.'), ); $form['registration']['user_email_verification'] = array( '#type' => 'checkbox', - '#title' => t('Set password'), + '#title' => t('Allow users to set their own password'), '#default_value' => !variable_get('user_email_verification', TRUE) ? 1 : 0, '#description' => t("This will allow users to choose their initial password when registering. If 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.
    NOTE: If you enable this feature, you should edit the Welcome, no approval required text -- more help in writing the e-mail message can be found at LoginToboggan help.", array('!settings' => url('admin/user/settings'), '!help' => url('admin/help/logintoboggan'))), ); @@ -645,7 +740,7 @@ function logintoboggan_main_settings(&$f '#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. Add new roles.', array('!url' => url('admin/user/roles'))), + '#description' => t('If "Allow users to set their own 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. Add new roles.', array('!url' => url('admin/user/roles'))), ); $purge_options = array( @@ -669,14 +764,14 @@ function logintoboggan_main_settings(&$f '#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 last login 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.") + '#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 last login has passed. This can be used to automatically purge spambot registrations. Note: this requires cron, and also requires that the 'Allow users to set their own password' option above is enabled.") ); $form['registration']['logintoboggan_immediate_login_on_register'] = array( '#type' => 'checkbox', - '#title' => t('Immediate login'), + '#title' => t('Allow users to login immediately upon registering'), '#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."), + '#description' => t("If set, the user will be logged in immediately after registering. Note this only applies if the 'Allow users to set their own password' option above is enabled."), ); $form['registration']['redirect'] = array( @@ -690,7 +785,7 @@ function logintoboggan_main_settings(&$f '#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 Immediate login 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 node/35, or to the <front> page. You may also use %uid as a variable, and the user\'s user ID will be substituted in the path.'), + '#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 Allow users to login immediately upon registering 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 node/35, or to the <front> page. You may also use %uid as a variable, and the user\'s user ID will be substituted in the path.'), ); $form['registration']['redirect']['logintoboggan_redirect_on_confirm'] = array( @@ -712,19 +807,21 @@ function logintoboggan_main_settings(&$f else { $disabled = $site403; } - $options = array($disabled => $_disabled, 'toboggan/denied' => $_enabled); + $options = array( + $disabled => t('Leave as the site default'), + 'toboggan/denied' => t('Show login form on access denied page'), + ); $form['other']['site_403'] = array( '#type' => 'radios', - '#title' => t('Present login form on access denied (403)'), + '#title' => t('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', + '#type' => 'checkbox', '#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.') ); Index: unifiedlogin.js =================================================================== RCS file: unifiedlogin.js diff -N unifiedlogin.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ unifiedlogin.js 29 May 2008 20:02:58 -0000 @@ -0,0 +1,38 @@ +/* $Id$ */ + +if (Drupal.jsEnabled) { + + // For compatibility with non-js browsers, we hide the #register-form here + // it is important that this CSS gets added early so the form doesn't + // appear while the page is loading (before $(document).ready() fires) + $('').appendTo('head'); + + $(document).ready(function() { + // Attach behaviors to the links so that they show/hide forms appropriately. + $('#toboggan-unified #register-link').click(function() { + $(this).addClass('lt-active').blur(); + $('#toboggan-unified #login-link').removeClass('lt-active'); + $('#toboggan-unified #register-form').show(); + $('#toboggan-unified #login-form').hide(); + return false; + }); + $('#toboggan-unified #login-link').click(function() { + $(this).addClass('lt-active').blur(); + $('#toboggan-unified #register-link').removeClass('lt-active'); + $('#toboggan-unified #login-form').show(); + $('#toboggan-unified #register-form').hide(); + return false; + }); + + switch(Drupal.settings.lt.activeForm) { + case 'register': + $('#toboggan-unified #register-link').click(); + break; + case 'login': + default: + $('#toboggan-unified #login-link').click(); + break; + } + + }); +} \ No newline at end of file