function ip_login_form_alter in IP Login 6.2
Same name and namespace in other branches
- 7.3 ip_login.module \ip_login_form_alter()
- 7.2 ip_login.module \ip_login_form_alter()
Implementation of hook_form_alter().
File
- ./
ip_login.module, line 176 - Allow user login by IP addresses, ranges or wildcards.
Code
function ip_login_form_alter(&$form, &$form_state, $form_id) {
// @todo should call hook_theme ideally
switch ($form_id) {
case 'user_login':
$matched_uid = ip_login_check(ip_address());
if ($matched_uid > 0) {
$link_text = t(variable_get('ip_login_link_login_page', 'Log in automatically'));
if (drupal_strlen($link_text)) {
// hide if no link text
$link_help = t(variable_get('ip_login_link_login_page_help', "Your computer's IP address has been matched and validated."));
$markup = '<br/>';
$markup .= '<ul class="item-list">';
$markup .= '<li><strong>' . l($link_text, ATTEMPT_IP_LOGIN, array(
'query' => array(
'ip_login_override_pages' => 'yes',
),
)) . '</strong>';
if (drupal_strlen($link_help)) {
$markup .= '<br/><small>' . filter_xss_admin($link_help) . '</small>';
}
$markup .= '</li></ul>';
$form['ip_login'] = array(
'#value' => filter_xss($markup),
'#weight' => variable_get('ip_login_link_login_page_weight', -10),
);
}
}
break;
case 'user_login_block':
$matched_uid = ip_login_check(ip_address());
if ($matched_uid > 0) {
$link_text = t(variable_get('ip_login_link_login_block', 'Log in automatically'));
if (drupal_strlen($link_text)) {
// hide if no link text
$markup = '<ul class="item-list">';
$markup .= '<li><strong>' . l($link_text, ATTEMPT_IP_LOGIN, array(
'query' => array(
'ip_login_override_pages' => 'yes',
),
)) . '</strong>';
$markup .= '</li></ul>';
$form['ip_login'] = array(
'#value' => filter_xss($markup),
'#weight' => variable_get('ip_login_link_login_block_weight', -10),
);
}
}
break;
}
}