コード例 #1
0
ファイル: CaptchaValidator.php プロジェクト: advOpk/pwm
 /**
  * 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
ファイル: CaptchaViewHelper.php プロジェクト: advOpk/pwm
 /**
  * Returns Captcha-Image String
  *
  * @return string HTML-Tag for Captcha image
  */
 public function render()
 {
     $this->captchaEngine->setConfiguration($this->settings);
     return $this->captchaEngine->render();
 }