# 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, after 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.7) +++ contributions/modules/login_security/login_security.module Locally Modified (Based On 1.12.2.7) @@ -247,18 +247,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 = _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 @@ -326,14 +322,10 @@ // Should the user be advised about the remaining login attempts? $notice_user = variable_get('login_security_notice_attempts_available', LOGIN_SECURITY_NOTICE_ATTEMPTS_AVAILABLE); if (($notice_user == TRUE) && ($variables['%user_block_attempts'] > 0)) { - // 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'); } } - } /** * Save the login attempt in the tracking database: user name and ip address. @@ -367,7 +359,7 @@ $block->status = 0; drupal_write_record('access', $block); watchdog('login_security', 'Banned IP address %ip because of security configuration.', $variables, WATCHDOG_NOTICE); - form_set_error('void', t(variable_get('login_security_host_hard_banned', LOGIN_SECURITY_HOST_HARD_BANNED), $variables)); + form_set_error('void', login_security_t(variable_get('login_security_host_hard_banned', LOGIN_SECURITY_HOST_HARD_BANNED), $variables)); } /** @@ -379,7 +371,7 @@ */ function login_user_block_user_name($variables) { if ($variables['%uid'] > 1) { - 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)); // Modifying the user table is not an option so it disables the user hooks. Need to do // firing the hook so user_notifications can be used. // db_query("UPDATE {users} SET status = 0 WHERE uid = %d", $uid); @@ -395,8 +387,8 @@ 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); } @@ -434,9 +426,18 @@ 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 function returns. + */ +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.6) +++ contributions/modules/login_security/login_security.test Locally Modified (Based On 1.1.2.6) @@ -130,30 +130,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.')); }