You are here

function ip_login_block_view in IP Login 7.2

Same name and namespace in other branches
  1. 7.3 ip_login.module \ip_login_block_view()

Implementation of hook_block_view

Makes simple a 'Automatic login' link available for those not wanting to use the overridden 'User Login' block.

File

./ip_login.module, line 268
Allow user login by IP addresses, ranges or wildcards.

Code

function ip_login_block_view($delta = '') {

  // only show for anonymous users who can log in
  global $user;
  if ($user->uid > 0 || !ip_login_is_possible()) {
    return;
  }
  if ($delta != 'ip-login-link') {
    return;
  }

  // build simple block
  // @todo should be a hook_theme call
  $link_text = t(variable_get('ip_login_link_login_block', 'Log in automatically'));
  $markup = '<div class="ip-login-available"><span class="ip-login-link">';
  $markup .= l($link_text, ATTEMPT_IP_LOGIN, array(
    'query' => array(
      'ip_login_override_pages' => 'yes',
    ),
  ));
  $markup .= '</span></div>';
  $block = array(
    'subject' => t('Automatic login'),
    'content' => $markup,
  );
  return $block;
}