function autologout_block_view in Automated Logout 7.2
Same name and namespace in other branches
- 7.4 autologout.module \autologout_block_view()
Implements hook_block_view().
File
- ./
autologout.module, line 72 - Used to automagically log out a user after a preset time, AjK May 2006
Code
function autologout_block_view($delta = '') {
global $user;
$block = array();
_autologout_debug("autologout_block_view()");
if (!_autologout_local_settings('enabled')) {
return;
}
if ($user->uid < 1 || _autologout_by_role()) {
_autologout_debug(" block doesn't apply");
return;
}
$block['subject'] = filter_xss_admin(_autologout_local_settings('block_title'));
$refresh = (int) _autologout_local_settings('refresh_delta');
$timeout = _autologout_local_settings('timeout');
$redirect_url = filter_xss_admin(_autologout_local_settings('redirect_url'));
if (module_exists('jstimer') && module_exists('jst_timer')) {
$block['content'] = theme('jstimer', array(
'widget_name' => 'jst_timer',
'widget_args' => array(
'interval' => $timeout,
'tc_redir' => $redirect_url,
'threshold' => 5,
'format_txt' => filter_xss_admin(variable_get('autologout_jstimer_format', '%hours%:%mins%:%secs%')),
'complete' => t('You have been automatically logged out due to inactivity.') . ' ' . ($refresh ? ' ' . t('This page will refresh in %refresh seconds.', array(
'%refresh' => $refresh,
)) : ''),
'no_js_txt' => t('You will be logged out in !time if this page is not refreshed before then.', array(
'!time' => format_interval($timeout),
)),
),
));
}
else {
$block['content'] = t('You will be logged out in !time if this page is not refreshed before then.', array(
'!time' => format_interval($timeout),
));
}
$logout_message = filter_xss_admin(_autologout_local_settings('logout_message'));
if ($logout_message != '') {
$block['content'] .= '<span style="display:none" class="tc_msg">' . $logout_message . '</span>';
}
$block['content'] .= '</span>';
return $block;
}