function login_security_form_alter in Login Security 5
Same name and namespace in other branches
- 8 login_security.module \login_security_form_alter()
- 6 login_security.module \login_security_form_alter()
- 7 login_security.module \login_security_form_alter()
- 2.x login_security.module \login_security_form_alter()
Implementation of hook_form_alter().
File
- ./
login_security.module, line 93 - Login Security
Code
function login_security_form_alter($form_id, &$form) {
switch ($form_id) {
case 'user_login':
case 'user_login_block':
// Attach a new validatdor for the name field
$form['name']['#validate']['login_security_validate'] = array();
// Change to do soft-blocking here, see issue: http://drupal.org/node/493164
// We alter the form here, and still show the message in the validation
$variables = _login_security_get_variables_by_name(check_plain($form['name']['#value']));
//drupal_set_message("<pre>".print_r($form,1)."</pre>");
// Check for host login attempts: Soft
if ($variables['%soft_block_attempts'] >= 1) {
if ($variables['%ip_current_count'] >= $variables['%soft_block_attempts']) {
//Alter current form, so user will not be able to submit it
// 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', strtr(variable_get('login_security_host_soft_banned', LOGIN_SECURITY_HOST_SOFT_BANNED), $variables));
unset($form['submit']);
}
}
break;
case 'user_admin_settings':
if (user_access('administer users')) {
$form['login_security'] = array(
'#type' => 'fieldset',
'#title' => t('Login Security settings'),
'#weight' => 0,
'#collapsible' => FALSE,
);
$form['login_security'][] = login_security_build_admin_form();
}
break;
}
}