public function executeSendPassword(sfWebRequest $request) { // try to find the user by the given E-Mail-Address $user = Doctrine::getTable('User')->findOneByEmail($request->getParameter('email')); if ($user) { // delete all previous recovery tokens Doctrine_Query::create()->delete('Token t')->where('t.user_id=? AND action=?', array($user->getId(), Token::$ACTION_RECOVER))->execute(); // generate recover token $token = new Token(); $token->setUserId($user->getId()); $token->setAction(Token::$ACTION_RECOVER); $token->save(); // sending user email $html = $this->getPartial('recoverEmail', array('user' => $user, 'token' => $token)); $subject = sfContext::getInstance()->getI18N()->__('Your TimeHive password'); MailSender::createInstance()->send($user['email'], $subject, $html); $this->getUser()->setFlash('send_pwd_failure', $this->getContext()->getI18N()->__('An email with instructions to choose a new password has been sent to you.')); $this->redirect('login/index'); } else { $this->getUser()->setFlash('send_pwd_failure', $this->getContext()->getI18N()->__('There is no such e-mail address in the our database!')); $this->redirect('login/index'); } }