示例#1
0
 public function __construct(User $user = null, $title = null, $body = null)
 {
     $this->created = new \DateTime();
     if (isset($user)) {
         $this->author = $user;
         $user->addPost($this);
     }
     if (isset($title)) {
         $this->title = $title;
     }
     if (isset($body)) {
         $this->body = $body;
     }
 }
 public function indexAction()
 {
     $form = new RegisterForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $user = new User($data['userName'], $data['email'], $data['password'], $data['firstName'], $data['lastName']);
             //Set the profile
             $profile = new Profile();
             $user->setProfile($profile);
             $this->dm->persist($user);
             $this->dm->flush();
             $this->flashMessenger()->addSuccessMessage('You have successfully registered! Please sign in to your account.');
             return $this->redirect()->toRoute('user_login');
         }
     }
     return array('form' => $form);
 }
 public function signinAction()
 {
     if ($this->getRequest()->isPost()) {
         if ($this->params()->fromPost('password') === $this->params()->fromPost('passwordconfirm')) {
             $dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');
             $user = new User();
             $user->setLogin($this->params()->fromPost('email'));
             $user->setPassword(md5($this->params()->fromPost('password')));
             $user->setEmail($this->params()->fromPost('email'));
             $dm->persist($user);
             $dm->flush();
             $lastId = $user->getId();
             $this->getLogin($this->params()->fromPost('email'), $this->params()->fromPost('password'));
             $this->flashMessenger()->addInfoMessage('Usuario creato correctamente');
             return $this->redirect()->toRoute('post', array('controller' => 'post', 'action' => 'create'));
         }
         $this->flashMessenger()->addErrorMessage('Los datos introducidos son incorrectos. Las contraseñas no coinciden');
         return $this->redirect()->toRoute('login', array('controller' => 'login', 'action' => 'signin'));
     }
     return new ViewModel();
 }
 /**
  * {@inheritDoc}
  */
 public function setIgnoredFields(array $fields)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setIgnoredFields', array($fields));
     return parent::setIgnoredFields($fields);
 }
示例#5
0
 /**
  *
  * @param User $recipient
  */
 public function setRecipients(User $recipient)
 {
     $this->recipients[] = $recipient;
     $recipient->addMessage($this);
 }