public function addAction() { $error = ''; $token = $this->params()->fromRoute('token'); $form = new RegisterForm(); $request = $this->getRequest(); if ($request->isPost()) { $exUser = $this->getEntityManager()->getRepository('Profile\\Entity\\User')->findByusername($request->getPost('username')); if (empty($exUser)) { $user = new User(); $filter = new RegisterFilter(); $form->bind($user); $form->setInputFilter($filter->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $check = $this->getProfileService()->addUser($user, $form, $request); if ($check === true) { return $this->redirect()->toRoute('home'); } else { return array('form' => $form); } } } else { $this->flashMessenger()->addErrorMessage('Der Username ist bereits vergeben. Bitte wähle einen anderen.'); } } return array('form' => $form, 'error' => $this->flashMessenger()->getErrorMessages()); }
/** * edit a given Profile * @param \Profile\Form\RegisterForm $form * @param Profile\Entity\User $entity * @return boolean */ public function editProfile($form, $entity) { if ($form->isValid()) { $homepage = trim($form->get('homepage')->getValue(), 'http://'); $entity->setHomepage($homepage); $entity->setUser($this->getUserById($this->getIdentity()->getUserId())); $user = $this->getUserMapper()->save($entity); return true; } return false; }
/** * registerAction * @return \Zend\Http\Response|multitype:\Profile\Form\RegisterForm |multitype:\Profile\Form\RegisterForm multitype: */ public function registerAction() { $error = ''; $token = $this->params()->fromRoute('token'); if (!empty($token)) { $check = $this->getProfileService()->confirmUser($token); if ($check === true) { $this->flashMessenger()->addMessage('Freischaltung erfolgreich. Du kannst dich nun einloggen.'); return $this->redirect()->toRoute('login'); } $this->flashMessenger()->addErrorMessage('Der angegebene Token ist ungültig oder der Account wurde bereits' . ' aktiviert. Bitte registriere dich oder logge dich ein.'); } $form = new RegisterForm(); $request = $this->getRequest(); if ($request->isPost()) { $exUser = $this->getEntityManager()->getRepository('Profile\\Entity\\User')->findByusername($request->getPost('username')); if (empty($exUser)) { $user = new User(); $filter = new RegisterFilter(); $form->bind($user); $form->setInputFilter($filter->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $check = $this->getProfileService()->addUser($user, $form, $request); if ($check === true) { return $this->redirect()->toRoute('home'); } else { return array('form' => $form); } } } else { $this->flashMessenger()->addErrorMessage('Der Username ist bereits vergeben. Bitte wähle einen anderen.'); } } return array('form' => $form, 'error' => $this->flashMessenger()->getErrorMessages()); }