diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module index 4a9136e..6baf609 100644 --- a/core/modules/openid/openid.module +++ b/core/modules/openid/openid.module @@ -122,18 +122,7 @@ function openid_user_logout($account) { /** * Implements hook_form_FORM_ID_alter(). */ -function openid_form_user_login_block_alter(&$form, &$form_state) { - _openid_user_login_form_alter($form, $form_state); -} - -/** - * Implements hook_form_FORM_ID_alter(). - */ function openid_form_user_login_alter(&$form, &$form_state) { - _openid_user_login_form_alter($form, $form_state); -} - -function _openid_user_login_form_alter(&$form, &$form_state) { $form['#attached']['library'][] = array('openid', 'drupal.openid'); if (!empty($form_state['input']['openid_identifier'])) { $form['name']['#required'] = FALSE; diff --git a/core/modules/user/user.module b/core/modules/user/user.module index c57fca2..ec020bb 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -730,36 +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, - ); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array('#type' => 'submit', - '#value' => t('Log in'), - ); - $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); - return $form; -} - /** * Implements hook_block_info(). */ @@ -836,8 +806,41 @@ 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'); + 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)); + // Build action links. + $links = array(); + if (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) { + $links['create-account-link'] = array( + 'title' => t('Create new account'), + 'href' => 'user/register', + 'attributes' => array( + 'title' => t('Create a new user account.'), + ), + ); + } + $links['request-password-link'] = array( + 'title' => t('Request new password'), + 'href' => 'user/password', + 'attributes' => array( + 'title' => t('Request new password via e-mail.'), + ), + ); + // Build a block as renderable array. $block['subject'] = t('User login'); - $block['content'] = drupal_get_form('user_login_block'); + $block['content'] = array( + 'form' => $form, + 'links' => array( + '#theme' => 'links', + '#links' => $links, + ), + ); } return $block; @@ -1551,34 +1554,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; }