Doc = &$Doc; $form = $this->_getNewForm(); $User = SiteMap::getObj('User/User.php'); if ($_REQUEST['action'] == '') $form->exec(); switch ($_REQUEST['action']) { case 'send_email': if (!$form->validate()) { $form->exec(); break; } $error = $User->generateNewAuthCode($_POST['email']); require_once('class/HTTP.php'); skHTTP::redirect(Constant::get('BASE_URL').'/check_email.html'); exit(); break; default: if ( $this->Doc->UserAuth->isLogged() ) { require_once('class/HTTP.php'); skHTTP::redirect(Constant::get('BASE_URL').'/home'); exit(); } break; } } function _getNewForm() { require_once 'class/Form/Form.class.php'; $form = new Form($this->Doc, 'forgot', 'post'); $form->addElement('hidden', 'action', 'send_email'); $form->addElement('text', 'email', 'Enter your email', array('style'=> 'width:200px;')); $form->addRule('email', 'Email is incorect', 'email', null, 'client'); $form->addRule('email', 'Email is incorect', 'email'); $data = array(); $form->setDefaults($data); $form->setCancelType(NULL); $form->_requiredNote = NULL; $form->submitTitle = 'Send'; $form->addRuleRequired(array('email')); $form->addFormRule(array(&$this, 'validForm')); return $form; } function validForm($fields) { $User = SiteMap::getObj('User/User.php'); $data = $User->getUserByEmail($fields['email']); if ( count($data)===0 ) { return array('email' => 'There is no user registered with the e-mail address provided.
Please enter valid email address.'); } return true; } } ?>