? .DS_Store ? .svn ? po/.svn ? translations/.svn 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 25 Sep 2009 12:57:21 -0000 @@ -1,3 +1,5 @@ +/* $Id$ */ + div.toboggan-container { text-align: center; } @@ -20,4 +22,40 @@ 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; +} + +.toboggan-unified.login #register-form { + display: none; +} + +.toboggan-unified.register #login-form { + display: none; } \ No newline at end of file Index: logintoboggan.module =================================================================== RCS file: /cvs/drupal/contributions/modules/logintoboggan/logintoboggan.module,v retrieving revision 1.133.2.16 diff -u -p -r1.133.2.16 logintoboggan.module --- logintoboggan.module 31 Aug 2009 10:52:57 -0000 1.133.2.16 +++ logintoboggan.module 25 Sep 2009 12:57:22 -0000 @@ -67,6 +67,8 @@ function logintoboggan_help($path, $arg)
  • Optionally redirect the user to a specific page when using the 'Immediate login' 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.
  • Optionally have unvalidated users purged from the system at a pre-defined interval (please read the CAVEATS section of INSTALL.txt for important information on configuring this feature!).
  • These features may be turned on or off in the Login Toboggan settings.

    @@ -175,6 +177,11 @@ function logintoboggan_form_alter(&$form break; case 'user_login': + if (variable_get('logintoboggan_forgot_password_link', 0) || variable_get('logintoboggan_unified_login', 0)) { + $form['lost_password'] = array( + '#value' => '
    ' . l(t('Request new 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', '')) { @@ -519,6 +526,79 @@ 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) { @@ -558,6 +638,9 @@ function logintoboggan_theme() { 'lt_login_successful_message' => array( 'arguments' => array('account'), ), + 'lt_unified_login_page' => array( + 'arguments' => array('login_form' => NULL, 'register_form' => NULL), + ), ); } @@ -650,6 +733,20 @@ function logintoboggan_main_settings(&$f '#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' => 'checkbox', + '#title' => t('Present a unified login and registration page'), + '#default_value' => variable_get('logintoboggan_unified_login', 0), + '#description' => t("Use one page for both login and register instead of Drupal's tabbed login/registration/password pages."), + ); + + $form['login']['logintoboggan_forgot_password_link'] = array( + '#type' => 'checkbox', + '#title' => t('Show a "forgot password" link on the login form'), + '#default_value' => variable_get('logintoboggan_forgot_password_link', 0) || variable_get('logintoboggan_unified_login', 0), + '#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'), \ No newline at end of file Index: unifiedlogin.js =================================================================== RCS file: unifiedlogin.js diff -N unifiedlogin.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ unifiedlogin.js 25 Sep 2009 12:56:35 -0000 @@ -0,0 +1,38 @@ +/* $Id$ */ + +Drupal.behaviors.myBehavior = function (context) { + + // 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