function validate($vars = null, $canAutoFill = false)
{
if (is_null($vars)) {
$vars = $this->_vars;
}
/* Get submitted status. */
if ($this->isSubmitted() || $canAutoFill) {
/* Form was submitted or can autofill; check for any variable
* types' onSubmit(). */
$this->onSubmit($vars);
/* Recheck submitted status. */
if (!$this->isSubmitted() && !$canAutoFill) {
return false;
}
} else {
/* Form has not been submitted; return false. */
return false;
}
$message = '';
$this->_autofilled = true;
if ($this->_useFormToken) {
try {
$tokenSource = $GLOBALS['injector']->getInstance('Horde_Token');
$passedToken = $vars->get($this->_name . '_formToken');
if (!empty($passedToken) && !$tokenSource->verify($passedToken)) {
$this->_errors['_formToken'] = Horde_Form_Translation::t("This form has already been processed.");
}
} catch (Horde_Exception $e) {
}
if (!$GLOBALS['session']->get('horde', 'form_secrets/' . $passedToken)) {
$this->_errors['_formSecret'] = Horde_Form_Translation::t("Required secret is invalid - potentially malicious request.");
}
}
foreach ($this->getVariables() as $var) {
$this->_autofilled = $var->_autofilled && $this->_autofilled;
if (!$var->validate($vars, $message)) {
$this->_errors[$var->getVarName()] = $message;
}
}
if ($this->_autofilled) {
unset($this->_errors['_formToken']);
}
foreach ($this->_hiddenVariables as $var) {
if (!$var->validate($vars, $message)) {
$this->_errors[$var->getVarName()] = $message;
}
}
return $this->isValid();
}