示例#1
0
 /**
  * Validation of given Params
  *
  * @param \In2code\Powermail\Domain\Model\Mail $mail
  * @return bool
  */
 public function isValid($mail)
 {
     if (!$this->formHasCaptcha($mail->getForm())) {
         return TRUE;
     }
     foreach ($mail->getAnswers() as $answer) {
         if ($answer->getField()->getType() !== 'captcha') {
             continue;
         }
         $this->captchaArgumentFound = TRUE;
         if (!$this->captchaEngine->validCode($answer->getValue(), $this->clearSession)) {
             $this->setErrorAndMessage($answer->getField(), 'captcha');
         }
     }
     // if no captcha arguments given (maybe deleted from DOM)
     if (!$this->captchaArgumentFound) {
         $this->addError('captcha', 0);
         $this->setIsValid(FALSE);
     }
     return $this->getIsValid();
 }
示例#2
0
 /**
  * Returns Captcha-Image String
  *
  * @return string HTML-Tag for Captcha image
  */
 public function render()
 {
     $this->captchaEngine->setConfiguration($this->settings);
     return $this->captchaEngine->render();
 }