function login_history_block_view in Login History 7
Implements hook_block_view().
File
- ./
login_history.module, line 148 - The login history module.
Code
function login_history_block_view($delta = '') {
switch ($delta) {
case 'login_history_last':
if (user_is_anonymous()) {
return;
}
// Get information about the user's last login. If no information is
// found, the block is not displayed.
if ($last_login = login_history_last_login()) {
$hostname = $last_login->hostname == ip_address() ? t('this IP address') : $last_login->hostname;
$user_agent = $last_login->user_agent == $_SERVER['HTTP_USER_AGENT'] ? t('this browser') : $last_login->user_agent;
$output = '<p>' . t('You last logged in from @hostname using @user_agent.', array(
'@hostname' => $hostname,
'@user_agent' => $user_agent,
)) . '</p>';
if (user_access('view own login history')) {
global $user;
$output .= '<span class="read-more">' . l(t('View your login history.'), 'user/' . $user->uid . '/login-history') . '</span>';
}
$block['subject'] = t('Last login');
$block['content'] = $output;
return $block;
}
}
}