private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate required fields
$this->frm->getField('name')->isFilled(FL::err('NameIsRequired'));
$this->frm->getField('email')->isEmail(FL::err('EmailIsInvalid'));
$this->frm->getField('message')->isFilled(FL::err('QuestionIsRequired'));
if ($this->frm->isCorrect()) {
$spamFilterEnabled = $this->get('fork.settings')->get('Faq', 'spamfilter');
$variables['sentOn'] = time();
$variables['name'] = $this->frm->getField('name')->getValue();
$variables['email'] = $this->frm->getField('email')->getValue();
$variables['message'] = $this->frm->getField('message')->getValue();
if ($spamFilterEnabled) {
// if the comment is spam alter the comment status so it will appear in the spam queue
if (FrontendModel::isSpam($variables['message'], SITE_URL . FrontendNavigation::getURLForBlock('Faq'), $variables['name'], $variables['email'])) {
$this->status = 'errorSpam';
return;
}
}
$from = $this->get('fork.settings')->get('Core', 'mailer_from');
$to = $this->get('fork.settings')->get('Core', 'mailer_to');
$replyTo = $this->get('fork.settings')->get('Core', 'mailer_reply_to');
$message = Message::newInstance(sprintf(FL::getMessage('FaqOwnQuestionSubject'), $variables['name']))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml('/Faq/Layout/Templates/Mails/OwnQuestion.html.twig', $variables, true);
$this->get('mailer')->send($message);
$this->status = 'success';
}
}
}