/** * Action send. * * @return void */ public function sendAction() { $form = new Application_Form_Forgot(); $tableUser = new Tri_Db_Table('user'); $data = $this->_getAllParams(); if ($form->isValid($data)) { $email = $this->_getParam('email'); $user = $tableUser->fetchRow(array('email = ?' => $email)); if (!$user->id) { $this->_helper->_flashMessenger->addMessage('user not avaliable'); $this->_redirect('forgot/'); } $this->view->name = $user->name; $this->view->url = $this->encryptUrl($user); $mail = new Zend_Mail(APP_CHARSET); $mail->setBodyHtml($this->view->render('forgot/mail.phtml')); $mail->setFrom(FROM_EMAIL, FROM_NAME); $mail->setSubject($this->view->translate('forgot')); $mail->addTo($user->email, $user->name); $mail->send(); $this->_helper->_flashMessenger->addMessage('Success'); $this->_redirect('forgot/'); } $this->_helper->_flashMessenger->addMessage('Error'); $this->_redirect('forgot/'); }
public function forgotAction() { $request = $this->getRequest(); $this->view->form = $form = new Application_Form_Forgot(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } $options = $request->getParams(); if ($request->isPost()) { if ($form->isValid($request->getPost())) { $model = new Application_Model_User(); $model = $model->fetchRow("email='{$options['email']}'"); if (false !== $model) { $Auth = new Base_Auth_Auth(); $Auth->recoverPassword($model); //$this->view->msg="Your password has been reset and emailed to your email address."; $msgNs = new Zend_Session_Namespace("app"); $msgNs->message = "Your password has been reset and emailed to your email address."; $form->reset(); return $this->_helper->redirector('forgot', 'index', "default"); } } } $msgNs = new Zend_Session_Namespace("app"); $this->view->msg = $msgNs->message; $msgNs->message = ""; }