00001 <?php
00002
00015
00016
00017
00018 class FormValidatorCaptcha extends FormValidator {
00019 var $captchaIdField;
00020
00028 function FormValidatorCaptcha(&$form, $field, $captchaIdField, $message) {
00029 parent::FormValidator($form, $field, 'required', $message);
00030 $this->captchaIdField = $captchaIdField;
00031 }
00032
00037 function isValid() {
00038 $captchaDao =& DAORegistry::getDAO('CaptchaDAO');
00039 $captchaId = $this->form->getData($this->captchaIdField);
00040 $captchaValue = $this->form->getData($this->field);
00041 $captcha =& $captchaDao->getCaptcha($captchaId);
00042 if ($captcha && $captcha->getValue() === $captchaValue) {
00043 $captchaDao->deleteCaptcha($captcha);
00044 return true;
00045 }
00046 return false;
00047
00048 }
00049 }
00050
00051 ?>