function _autologout_get_user_timeout in Automated Logout 6.4
Same name and namespace in other branches
- 7.4 autologout.module \_autologout_get_user_timeout()
Get a user's timeout in seconds.
Parameters
int $uid: (Optional) Provide a user's uid to get the timeout for. Default is the logged in user.
Return value
int The number of seconds the user can be idle for before being logged out. A value of 0 means no timeout.
6 calls to _autologout_get_user_timeout()
- AutologoutTestCase::assertAutotimeout in tests/
autologout.test - Assert the timeout for a particular user.
- autologout_autologout_prevent in ./
autologout.module - Implements hook_autologout_prevent().
- autologout_form_user_profile_form_alter in ./
autologout.module - Adds a field to user/edit to change that users logout.
- autologout_help in ./
autologout.module - Implements hook_help().
- autologout_init in ./
autologout.module - Implements hook_init().
File
- ./
autologout.module, line 611 - Used to automagically log out a user after a preset time.
Code
function _autologout_get_user_timeout($uid = NULL) {
if (is_null($uid)) {
// If $uid is not provided, use the logged in user.
global $user;
}
else {
$user = user_load($uid);
}
if ($user->uid == 0) {
// Anonymous doesn't get logged out.
return 0;
}
if (is_numeric($user_timeout = variable_get('autologout_user_' . $user->uid, FALSE))) {
// User timeout takes precedence.
return $user_timeout;
}
// Get role timeouts for user.
if (variable_get('autologout_role_logout', FALSE)) {
$user_roles = $user->roles;
$output = array();
$timeouts = _autologout_get_role_timeout();
foreach ($user_roles as $rid => $role) {
if (isset($timeouts[$rid])) {
$output[$rid] = $timeouts[$rid];
}
}
// Assign the lowest timeout value to be session timeout value.
if (!empty($output)) {
// If one of the user's roles has a unique timeout, use this.
return min($output);
}
}
// If no user or role override exists, return the default timeout.
return variable_get('autologout_timeout', 1800);
}