You are here

function autologout_timeout_validate in Automated Logout 7.4

Same name and namespace in other branches
  1. 6.4 autologout.module \autologout_timeout_validate()

Checks to see if timeout threshold is outside max/min values. Only done here to centrilize and stop repeated code. Hard coded min, configurable max.

Parameters

int $timeout: The timeout value in seconds to validate

int $max_timeout: (optional) A maximum timeout. If not set the current system default maximum is used.

Return value

bool

1 call to autologout_timeout_validate()
autologout_settings_validate in ./autologout.admin.inc
Settings validation.

File

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

Code

function autologout_timeout_validate($timeout, $max_timeout = NULL) {
  $validate = FALSE;
  if (is_null($max_timeout)) {
    $max_timeout = variable_get('autologout_max_timeout', '172800');
  }
  if (!is_numeric($timeout) || $timeout < 0 || $timeout > 0 && $timeout < 60 || $timeout > $max_timeout) {

    // Less then 60, greater then max_timeout and is numeric.
    // 0 is allowed now as this means no timeout.
    $validate = FALSE;
  }
  else {
    $validate = TRUE;
  }
  return $validate;
}