*/ WBClass::load('WBPAT_Forms_Rule'); /** * patForms Rule User Activation Code * * Verify activation code and activate user on the fly * * @version 0.1.0 * @package Wombat * @subpackage patForms */ class patForms_Rule_UserActivationCode extends WBPAT_Forms_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', 'Code doesn\'t match.'), ); 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) { $value = $element->getValue(); if (empty($value)) { $this->addValidationError(1); return false; } $reg = WBClass::create('WBUser_Register'); /** @var $reg WBUser_Register */ $id = $reg->approve($value); if ($id) { return true; } $this->addValidationError(1); return false; } } ?>