You are here

function autologout_user_profile_submit in Automated Logout 7.4

Same name and namespace in other branches
  1. 8 autologout.module \autologout_user_profile_submit()
  2. 6.4 autologout.module \autologout_user_profile_submit()

Handle submission of timeout threshold in user/edit.

1 string reference to 'autologout_user_profile_submit'
autologout_form_user_profile_form_alter in ./autologout.module
Adds a field to user/edit to change that users logout.

File

./autologout.module, line 326
Used to automagically log out a user after a preset time.

Code

function autologout_user_profile_submit(&$form, &$form_state) {
  global $user;
  $current_uid = $user->uid;
  $userid = $form_state['user']->uid;
  $access = FALSE;
  if (user_access('change own logout threshold') && $current_uid == $userid || user_access('administer autologout')) {
    $access = TRUE;
  }

  // Access is reused here as a security measure. Not only will the element not
  // display but wont submit without access.
  if ($access) {
    $userid = $form_state['user']->uid;
    $val = trim($form_state['values']['autologout_user_' . $userid]);
    if (empty($val)) {
      variable_del('autologout_user_' . $userid);
    }
    else {
      variable_set('autologout_user_' . $userid, $val);
    }
  }
}