# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: contributions/modules/login_security/login_security.install --- contributions/modules/login_security/login_security.install Base (1.6.2.6) +++ contributions/modules/login_security/login_security.install Locally Modified (Based On 1.6.2.6) @@ -11,26 +11,26 @@ */ function login_security_schema() { $schema['login_security_track'] = array( - 'description' => t('Keeps track of failed login attempts and the associated IP address and user name.'), + 'description' => t('Keeps track of failed login attempts, as a pair of the IP address and user name.'), 'fields' => array( 'id' => array( 'type' => 'serial', 'not null' => TRUE, - 'description' => t("Hidden ID for each security event."), + 'description' => t("ID of each login event."), ), 'host' => array( 'type' => 'varchar', 'length' => 39, 'not null' => TRUE, 'default' => '', - 'description' => t("The ip address of the connection."), + 'description' => t("The IP address of the request."), ), 'name' => array( 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '', - 'description' => t("Username used in the login."), + 'description' => t("Clean username, submitted using the login form."), ), 'timestamp' => array( 'type' => 'int', @@ -98,7 +98,7 @@ 'length' => 39, 'not null' => TRUE, 'default' => '', - 'description' => t("The IP address of the connection."), + 'description' => t("The IP address of the request."), ) ); db_add_index($ret, 'login_security_track', 'host', array('host')); @@ -126,7 +126,7 @@ 'length' => 64, 'not null' => TRUE, 'default' => '', - 'description' => t("Username used in the login submission."), + 'description' => t("Clean username, after submitted using the login form."), ) ); db_change_field($ret, 'login_security_track', 'timestamp', 'timestamp', array( Index: contributions/modules/login_security/login_security.module --- contributions/modules/login_security/login_security.module Base (1.12.2.11) +++ contributions/modules/login_security/login_security.module Locally Modified (Based On 1.12.2.11) @@ -268,18 +268,14 @@ * @url http://drupal.org/node/493164 */ function login_security_soft_block_validate($form, &$form_state) { - $variables = _login_security_get_variables_by_name(check_plain($form['name']['#value'])); + $variables = $variables = _login_security_get_variables_by_name(check_plain($form_state['values']['name'])); // Check for host login attempts: Soft if ($variables['%soft_block_attempts'] >= 1) { if ($variables['%ip_current_count'] >= $variables['%soft_block_attempts']) { - // this loop is instead of doing t() because t() can only translate static strings, not variables. - foreach ($variables as $key => $value) { - $variables[$key] = theme('placeholder', $value); + form_set_error('submit', login_security_t(variable_get('login_security_host_soft_banned', LOGIN_SECURITY_HOST_SOFT_BANNED), $variables)); } - form_set_error('submit', strtr(variable_get('login_security_host_soft_banned', LOGIN_SECURITY_HOST_SOFT_BANNED), $variables)); } } -} /** * Implementation of form validate. This functions does more than just validating, but it's main @@ -346,13 +342,10 @@ $notice_user = variable_get('login_security_notice_attempts_available', LOGIN_SECURITY_NOTICE_ATTEMPTS_AVAILABLE); if (($notice_user == TRUE) && ($variables['%user_block_attempts'] > 0) && $variables['%user_block_attempts'] >= $variables['%user_current_count']) { // this loop is instead of doing t() because t() can only translate static strings, not variables. - foreach ($variables as $key => $value) { - $variables[$key] = theme('placeholder', $value); + drupal_set_message(login_security_t(variable_get('login_security_notice_attempts_message', LOGIN_SECURITY_NOTICE_ATTEMPTS_MESSAGE), $variables), 'warning'); } - drupal_set_message(strtr(variable_get('login_security_notice_attempts_message', LOGIN_SECURITY_NOTICE_ATTEMPTS_MESSAGE), $variables), 'warning'); } } - } /** * Remove tracked events or expire old ones. @@ -382,7 +375,7 @@ } /** - * Save the login attempt in the tracking database: user name and ip address. + * Save the login attempt in the tracking database: user name nd ip address. * * @param $name * user name to be tracked. @@ -414,7 +407,8 @@ $block->status = 0; drupal_write_record('access', $block); watchdog('login_security', 'Banned IP address %ip due to security configuration.', $variables, WATCHDOG_NOTICE, l(t('edit rule'), "admin/user/rules/edit/{$block->aid}", array('query' => array('destination' => 'admin/user/rules')))); - form_set_error('void', t(variable_get('login_security_host_hard_banned', LOGIN_SECURITY_HOST_HARD_BANNED), $variables)); + //Using form_set_error because it may disrupt current form submission. + form_set_error('void', login_security_t(variable_get('login_security_host_hard_banned', LOGIN_SECURITY_HOST_HARD_BANNED), $variables)); } /** @@ -441,19 +435,17 @@ // The watchdog alert is set to 'user' so it will show with other blocked user messages. watchdog('user', 'Blocked user %username due to security configuration.', $variables, WATCHDOG_NOTICE, l(t('edit user'), "user/{$variables['%uid']}/edit", array('query' => array('destination' => 'admin/user/user')))); // Also notify the user that account has been blocked. - form_set_error('void', t(variable_get('login_security_user_blocked', LOGIN_SECURITY_USER_BLOCKED), $variables)); + form_set_error('void', login_security_t(variable_get('login_security_user_blocked', LOGIN_SECURITY_USER_BLOCKED), $variables)); // Send admin email if (variable_get('login_security_user_blocked_email', LOGIN_SECURITY_USER_BLOCKED_EMAIL)) { $from = variable_get('site_mail', ini_get('sendmail_from')); $admin_mail = db_result(db_query("SELECT mail FROM {users} WHERE uid = 1")); - $subject = strtr(variable_get('login_security_user_blocked_email_subject', LOGIN_SECURITY_USER_BLOCKED_EMAIL_SUBJECT), $variables); - $body = strtr(variable_get('login_security_user_blocked_email_mody', LOGIN_SECURITY_USER_BLOCKED_EMAIL_BODY), $variables); - + $subject = login_security_t(variable_get('login_security_user_blocked_email_subject', LOGIN_SECURITY_USER_BLOCKED_EMAIL_SUBJECT), $variables); + $body = login_security_t(variable_get('login_security_user_blocked_email_mody', LOGIN_SECURITY_USER_BLOCKED_EMAIL_BODY), $variables); return drupal_mail('login_security', 'notify', $admin_mail, language_default(), $variables, $from, TRUE); } } - } } @@ -488,9 +480,19 @@ function login_security_mail($key, &$message, $variables) { switch ($key) { case 'notify': - $message['subject'] = strtr(variable_get('login_security_user_blocked_email_subject', LOGIN_SECURITY_USER_BLOCKED_EMAIL_SUBJECT), $variables); - $message['body'] = strtr(variable_get('login_security_user_blocked_email_mody', LOGIN_SECURITY_USER_BLOCKED_EMAIL_BODY), $variables); + $message['subject'] = login_security_t(variable_get('login_security_user_blocked_email_subject', LOGIN_SECURITY_USER_BLOCKED_EMAIL_SUBJECT), $variables); + $message['body'] = login_security_t(variable_get('login_security_user_blocked_email_mody', LOGIN_SECURITY_USER_BLOCKED_EMAIL_BODY), $variables); break; } } +/** + * This option is instead of doing t() because t() can only translate static strings, not variables. + */ +function login_security_t($message, $variables = array()) { + foreach ($variables as $key => $value) { + $variables[$key] = theme('placeholder', $value); + } + return strtr($message, $variables); +} + Index: contributions/modules/login_security/login_security.test --- contributions/modules/login_security/login_security.test Base (1.1.2.7) +++ contributions/modules/login_security/login_security.test Locally Modified (Based On 1.1.2.7) @@ -134,30 +134,30 @@ variable_set('login_security_last_access_timestamp', 1); $this->drupalLogin($normal_user); // this is the very first login ever, so there should be no previous login to show - $this->assertNoText(t('Your last login was '), t('Last login message not found.')); + $this->assertNoText(t('Your last login was'), t('Last login message not found.')); // even though they weren't logged in, they've been accessing pages, so this could show $this->assertText(t('Your last page access (site activity) was '), t('Last page access message not found.')); variable_set('login_security_last_login_timestamp', 0); variable_set('login_security_last_access_timestamp', 0); $this->drupalLogin($normal_user); - $this->assertNoText(t('Your last login was '), t('Last login message not found.')); + $this->assertNoText(t('Your last login was'), t('Last login message not found.')); $this->assertNoText(t('Your last page access (site activity) was '), t('Last page access message not found.')); variable_set('login_security_last_login_timestamp', 1); $this->drupalLogin($normal_user); - $this->assertText(t('Your last login was '), t('Last login message found.')); + $this->assertText(t('Your last login was'), t('Last login message found.')); $this->assertNoText(t('Your last page access (site activity) was '), t('Last page access message not found.')); variable_set('login_security_last_login_timestamp', 0); variable_set('login_security_last_access_timestamp', 1); $this->drupalLogin($normal_user); - $this->assertNoText(t('Your last login was '), t('Last login message not found.')); + $this->assertNoText(t('Your last login was'), t('Last login message not found.')); $this->assertText(t('Your last page access (site activity) was '), t('Last page access message found.')); variable_set('login_security_last_login_timestamp', 1); $this->drupalLogin($normal_user); - $this->assertText(t('Your last login was '), t('Last login message found.')); \ No newline at end of file + $this->assertText(t('Your last login was'), t('Last login message found.')); \ No newline at end of file $this->assertText(t('Your last page access (site activity) was '), t('Last page access message found.')); }