function autologout_user in Automated Logout 6
Same name and namespace in other branches
- 5 autologout.module \autologout_user()
- 6.2 autologout.module \autologout_user()
Implementation of hook_user().
File
- ./
autologout.module, line 235 - Used to automagically log out a user after a preset time, AjK May 2006
Code
function autologout_user($op, &$edit, &$account, $category = NULL) {
_autologout_debug("autologout_user({$op})");
if ($account->uid < 2) {
return;
// UID 0 or UID 1 not appliciable
}
if (!$category) {
$category = "account";
}
switch ($op) {
case 'login':
$_SESSION['lastaccess'] = time();
break;
case 'load':
if (_autologout_user_in_by_user_role($account)) {
$account->autologout = 0;
$obj = db_fetch_object(db_query("SELECT setting FROM {autologout} WHERE uid = %d", $account->uid));
if (isset($obj)) {
$account->autologout = (int) $obj->setting;
}
}
break;
case 'form':
if (_autologout_user_in_by_user_role($account) && 'account' == $category) {
$form = array();
$form[$category]['autologout'] = array(
'#type' => 'checkbox',
'#title' => t('Disable inactivity Automated Logout'),
'#default_value' => $account->autologout,
'#weight' => 10,
);
return $form;
}
break;
case 'update':
if (_autologout_user_in_by_user_role($account)) {
if (isset($edit['autologout'])) {
db_query("DELETE FROM {autologout} WHERE uid = %d", $account->uid);
db_query("INSERT INTO {autologout} SET uid = %d, setting = %d", $account->uid, $edit['autologout']);
unset($edit['autologout']);
}
}
break;
case 'delete':
db_query("DELETE FROM {autologout} WHERE uid = %d", $account->uid);
break;
}
return;
}