function _autologout_by_role in Automated Logout 6
Same name and namespace in other branches
- 5 autologout.module \_autologout_by_role()
- 7.2 autologout.module \_autologout_by_role()
Is the user in a role that we exclude from features defined by this module
Parameters
$passed_user: A drupal "user" object or default FALSE (use global $user)
Return value
bool TRUE if user s to be excluded, FALSE otherwise
2 calls to _autologout_by_role()
- autologout_block in ./
autologout.module - Implementation of hook_block().
- autologout_boot in ./
autologout.module - Implementation of hook_boot().
File
- ./
autologout.module, line 461 - Used to automagically log out a user after a preset time, AjK May 2006
Code
function _autologout_by_role($passed_user = FALSE) {
global $user;
// this bit I am unsure about, if I don't use the
// user_load() function here, I don't see my inserted
// value "autologout" in the global $user object ??
module_load_include('module', 'user');
if (FALSE == $passed_user) {
$local_user = user_load(array(
'uid' => $user->uid,
));
}
else {
$local_user = $passed_user;
}
foreach (user_roles(TRUE) as $role) {
switch (_autologout_local_settings($role)) {
case 0:
// Enforce for all in this role
break;
case 1:
// Exclude all users in this role
if (in_array($role, $local_user->roles)) {
return TRUE;
}
break;
case 2:
// Exclude user if user set to disable
if (in_array($role, $local_user->roles)) {
if (isset($local_user->autologout) && $local_user->autologout != 0) {
return TRUE;
}
}
break;
}
}
return FALSE;
}