function autologout_form_user_profile_form_alter in Automated Logout 7.4
Same name and namespace in other branches
- 6.4 autologout.module \autologout_form_user_profile_form_alter()
- 7.2 autologout.module \autologout_form_user_profile_form_alter()
Adds a field to user/edit to change that users logout.
File
- ./
autologout.module, line 279 - Used to automagically log out a user after a preset time.
Code
function autologout_form_user_profile_form_alter(&$form, $form_state) {
if ($form['#user_category'] != 'account') {
// Only include the timeout on main user profile.
return;
}
global $user;
$current_uid = $user->uid;
$userid = $form_state['user']->uid;
$access = FALSE;
// If user has access to change, and they are changing their own and only
// thier own timeout. Or they are an admin.
if (user_access('change own logout threshold') && $current_uid == $userid || user_access('administer autologout')) {
$access = TRUE;
}
if ($access) {
$form['autologout_user_' . $userid] = array(
'#type' => 'textfield',
'#title' => t('Your current logout threshold'),
'#default_value' => variable_get('autologout_user_' . $userid, ""),
'#size' => 8,
'#description' => t('How many seconds to give a user to respond to the logout dialog before ending their session.'),
'#element_validate' => array(
'_autologout_user_uid_timeout_validate',
),
);
$form['#submit'][] = 'autologout_user_profile_submit';
}
}