diff --git a/core/modules/openid/openid.js b/core/modules/openid/openid.js index 5b4bb08..d45f415 100644 --- a/core/modules/openid/openid.js +++ b/core/modules/openid/openid.js @@ -4,7 +4,7 @@ Drupal.behaviors.openid = { attach: function (context) { - var $login = $('#user-login-form'); + var $login = $('#user-login'); var $openid = $('#openid-login-form'); var cookie = $.cookie('Drupal.visitor.openid_identifier'); diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module index 49cc4c6..bea44d9 100644 --- a/core/modules/openid/openid.module +++ b/core/modules/openid/openid.module @@ -142,6 +142,7 @@ function openid_block_view_user_login_alter(&$block) { $block['content']['openid_login_form'] = drupal_get_form('openid_login_form'); $block['content']['openid_login_form']['#attributes']['class'][] = 'user-login-block'; $block['content']['openid_login_form']['openid_identifier']['#size'] = $block['content']['user_login_form']['name']['#size']; + $block['content']['openid_login_form']['#weight'] = 20; // Add links between the forms. $block['content']['user_login_form']['openid_link'] = array( @@ -153,7 +154,7 @@ function openid_block_view_user_login_alter(&$block) { '#attached' => array('css' => array( drupal_get_path('module', 'openid') . '/openid.css'), ), - '#weight' => 5, + '#weight' => 15, ); $block['content']['openid_login_form']['user_link'] = array( '#type' => 'link', @@ -161,7 +162,7 @@ function openid_block_view_user_login_alter(&$block) { '#href' => '#nogo', '#options' => array('external' => TRUE), '#attributes' => array('class' => array('user-link')), - '#weight' => 5, + '#weight' => 15, ); $block['content']['openid_login_form']['links'] = $block['content']['user_login_form']['links']; } @@ -187,7 +188,7 @@ function openid_login_form($form) { '#value' => url('openid/authenticate', array('absolute' => TRUE, 'query' => user_login_destination())), ); - $form['actions'] = array('#type' => 'actions'); + $form['actions'] = array('#type' => 'actions', '#weight' => 10); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in')); return $form; diff --git a/core/modules/user/user.module b/core/modules/user/user.module index e42002b..6c66529 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -730,41 +730,6 @@ function user_validate_current_pass(&$form, &$form_state) { } } -function user_login_block($form) { - $form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE)); - $form['#id'] = 'user-login-form'; - $form['#validate'] = user_login_default_validators(); - $form['#submit'][] = 'user_login_submit'; - $form['name'] = array('#type' => 'textfield', - '#title' => t('Username'), - '#maxlength' => USERNAME_MAX_LENGTH, - '#size' => 15, - '#required' => TRUE, - ); - $form['pass'] = array('#type' => 'password', - '#title' => t('Password'), - '#maxlength' => 60, - '#size' => 15, - '#required' => TRUE, - ); - $items = array(); - if (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) { - $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.')))); - } - $items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.')))); - $form['links'] = array( - '#theme' => 'item_list', - '#items' => $items, - '#weight' => 10, - ); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array('#type' => 'submit', - '#value' => t('Log in'), - '#weight' => 20, - ); - return $form; -} - /** * Implements hook_block_info(). */ @@ -841,8 +806,40 @@ function user_block_view($delta = '') { // For usability's sake, avoid showing two login forms on one page. if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) { + // Customize the login form. + $form = drupal_get_form('user_login'); + $form['#attributes']['class'][] = 'user-login-block'; + unset($form['name']['#attributes']['autofocus']); + unset($form['name']['#description']); + unset($form['pass']['#description']); + $form['name']['#size'] = 15; + $form['pass']['#size'] = 15; + $form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE)); + $form['actions']['#weight'] = 10; + // Build action links. + $items = array(); + if (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) { + $items['create_account'] = l(t('Create new account'), 'user/register', array( + 'attributes' => array( + 'title' => t('Create a new user account.'), + 'class' => array('create-account-link'), + ), + )); + } + $items['request_password'] = l(t('Request new password'), 'user/password', array( + 'attributes' => array( + 'title' => t('Request new password via e-mail.'), + 'class' => array('request-password-link'), + ), + )); + $form['links'] = array( + '#theme' => 'item_list', + '#items' => $items, + '#weight' => 20, + ); + // Build a block as renderable array. $block['subject'] = t('User login'); - $block['content']['user_login_form'] = drupal_get_form('user_login_block'); + $block['content']['user_login_form'] = $form; } return $block; @@ -1577,34 +1574,32 @@ function user_set_authmaps($account, $authmaps) { * @ingroup forms */ function user_login($form, &$form_state) { - global $user; - - // If we are already logged on, go to the user page instead. - if ($user->uid) { - drupal_goto('user/' . $user->uid); - } - // Display login form: - $form['name'] = array('#type' => 'textfield', + $form['name'] = array( + '#type' => 'textfield', '#title' => t('Username'), '#size' => 60, '#maxlength' => USERNAME_MAX_LENGTH, + '#description' => t('Enter your @s username.', array('@s' => config('system.site')->get('name'))), '#required' => TRUE, '#attributes' => array( 'autofocus' => 'autofocus', ), ); - $form['name']['#description'] = t('Enter your @s username.', array('@s' => config('system.site')->get('name'))); - $form['pass'] = array('#type' => 'password', + $form['pass'] = array( + '#type' => 'password', '#title' => t('Password'), + '#size' => 60, '#description' => t('Enter the password that accompanies your username.'), '#required' => TRUE, ); - $form['#validate'] = user_login_default_validators(); + $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in')); + $form['#validate'] = user_login_default_validators(); + return $form; }