Ejemplo n.º 1
0
 /**
  * Forgot method
  *
  * @param  string $redirect
  * @return void
  */
 public function forgot($redirect = null)
 {
     $this->prepareView('forgot.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav'), 'phire' => new Model\Phire()));
     $this->view->set('title', $this->view->i18n->__('Forgot'));
     $form = new Form\Forgot($this->request->getBasePath() . $this->request->getRequestUri(), 'post');
     // If form is submitted
     if ($this->request->isPost()) {
         $form->setFieldValues($this->request->getPost(), array('strip_tags' => null, 'htmlentities' => array(ENT_QUOTES, 'UTF-8')));
         // If form is valid, send reminder
         if ($form->isValid()) {
             $form->filter(array('strip_tags' => null, 'htmlentities' => array(ENT_QUOTES, 'UTF-8')));
             $user = new Model\User();
             $user->sendReminder($form->email, $this->project->module('Phire'));
             if (null !== $redirect) {
                 Response::redirect($redirect);
             } else {
                 $this->view->set('form', '    <p>' . $this->view->i18n->__('Thank you. A password reminder has been sent.') . '</p>');
                 $this->send();
             }
             // Else, re-render the form with errors
         } else {
             $this->view->set('form', $form);
             $this->send();
         }
         // Else, render the form
     } else {
         if ($this->project->getService('acl')->isAuth()) {
             $form->setFieldValues(array('email' => $this->sess->user->email));
         }
         $this->view->set('form', $form);
         $this->send();
     }
 }