public function AutologoutSettingsForm::timeoutValidate in Automated Logout 8
Validate timeout range.
Checks to see if timeout threshold is outside max/min values. Done here to centralize and stop repeated code. Hard coded min, configurable max.
Parameters
int $timeout: The timeout value in seconds to validate.
int $max_timeout: (optional) Maximum value of timeout. If not set, system default is used.
Return value
bool Return TRUE or FALSE
1 call to AutologoutSettingsForm::timeoutValidate()
- AutologoutSettingsForm::validateForm in src/
Form/ AutologoutSettingsForm.php - Form validation handler.
File
- src/
Form/ AutologoutSettingsForm.php, line 320
Class
- AutologoutSettingsForm
- Provides settings for autologout module.
Namespace
Drupal\autologout\FormCode
public function timeoutValidate($timeout, $max_timeout = NULL) {
$validate = TRUE;
if (is_null($max_timeout)) {
$max_timeout = $this
->config('autologout.settings')
->get('max_timeout');
}
if (!is_numeric($timeout) || $timeout < 0 || $timeout > 0 && $timeout < 60 || $timeout > $max_timeout) {
// Less than 60, greater than max_timeout and is numeric.
// 0 is allowed now as this means no timeout.
$validate = FALSE;
}
return $validate;
}