*/ WBClass::load('WBPAT_Forms_Rule'); /** * patForms Rule UserLogin * * Validate user data to login * * @version 0.1.0 * @package Wombat * @subpackage patForms */ class patForms_Rule_UserLogin 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', 'Login failed'), ); return true; } /** * method called by patForms or any patForms_Element to validate the * element or the form. * * @param object patForms form object */ public function applyRule( &$form, $type = PATFORMS_RULE_AFTER_VALIDATION ) { $values = $form->getValues(); WBClass::load( 'WBUser_Auth' ); $user = WBUser_Auth::getCurrent(); $id = $user->login( $values ); if( !$id ) { $this->addValidationError( 1 ); return false; } return true; } } ?>