コード例 #1
0
 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());
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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());
 }