*/ WBClass::load('WBPAT_Forms_Rule'); /** * patForms Rule Captcha * * Check value against current user's password * * @version 0.1.0 * @package Wombat * @subpackage patForms */ class patForms_Rule_Captcha extends patForms_Rule { /** * Initialize validation codes using gettext * * @access protected * @return bool $success Always returns true. * @see $attributeDefaults */ function loadValidatiorErrorCodes() { $this->validatorErrorCodes = array( 1 => patI18n::dgettext('wombat', 'The entered value doesn\'t match requested characters.'), ); return true; } /** * method called by patForms or any patForms_Element to validate the * element or the form. * * @param patForms_Element $form object * @return bool true on sucess */ public function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { $guess = $element->getValue(); if (empty($guess)) { $this->addValidationError(1); return false; } $sess = WBClass::create('patSession'); $ch = $sess->get('wb.service.captcha.txt'); $sess->clear('wb.service.captcha.txt'); if ($ch != $guess) { $this->addValidationError(1); return false; } return true; } } ?>