*/ WBClass::load('WBPAT_Forms_Rule'); /** * patForms Rule User Activation Code * * Verify activation code and activate user on the fly * * @version 0.2.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.'), 2 => patI18n::dgettext('wombat', 'Code not found. Either there is a spell error or this code was used before (which means your account is already approved).'), ); 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(2); return false; } $reg = WBClass::create('WBUser_Register'); /** @var $reg WBUser_Register */ $id = $reg->approve($value); if ($id) { return true; } $this->addValidationError(2); return false; } }