public function registerAction()
 {
     // Check if user has submitted the form
     // Create Contact Us form
     $form = new RegistrationForm();
     // Check if user has submitted the form
     $request = $this->getRequest();
     if ($request->isPost()) {
         // Fill in the form with POST data
         $form->setInputFilter(new RegistrationFilter($this->getServiceLocator()));
         $form->setData($request->getPost());
         // Validate form
         if ($form->isValid()) {
             // Get filtered and validated data
             $data = $form->getData();
             $data = $this->prepareData($data);
             $user = new Register();
             $user->exchangeArray($data);
             //$user->exchangeArray($form->getData());
             $this->getRegisterTable()->saveUser($user);
             $mailSender = new \Application\Service\MailSender();
             $messageBody = "Please, click the link to confirm your registration => " . $this->getRequest()->getServer('HTTP_ORIGIN') . $this->url()->fromRoute('application/default', array('controller' => 'registration', 'action' => 'confirm-email', 'id' => $user->usr_registration_token));
             $mailSender->sendContactMail('*****@*****.**', $user->usr_email, 'Your App Confirmation Email', $messageBody);
             $this->flashMessenger()->addMessage($user->usr_email);
             return $this->redirect()->toRoute('application/default', array('controller' => 'registration', 'action' => 'registration-success'));
         }
     }
     // Pass form variable to view
     return new ViewModel(array('form' => $form));
 }
Пример #2
0
 public function signupAction()
 {
     if (!$this->getRequest()->isPost()) {
         $this->redirect()->toUrl('/accounts/registration');
     }
     $post = $this->request->getPost();
     $formRegistration = new RegistrationForm('registration');
     $formRegistration->setData($post);
     if (!$formRegistration->isValid()) {
         $model = new ViewModel(array('formRegistration' => $formRegistration, 'message' => 'Test Error', 'error' => true));
         $model->setTemplate('accounts/registration');
         return $model;
     }
     $profileName = $post['profile_name'];
     $email = $post['email'];
     if ($this->getUsersTable()->getOneBy(array('profile_name' => $profileName))) {
         $model = new ViewModel(array('formRegistration' => $formRegistration, 'message' => 'Имя профиля уже существует.', 'error' => true));
         $model->setTemplate('registration');
         return $model;
     }
     if ($this->getUsersTable()->getOneBy(array('email' => $email))) {
         $model = new ViewModel(array('formRegistration' => $formRegistration, 'message' => 'E-mail уже существует.', 'error' => true));
         $model->setTemplate('registration');
         return $model;
     }
     $key = md5(microtime());
     $profile = $formRegistration->getData();
     $profile['password'] = md5($profile['password']);
     $profile['is_active'] = 0;
     $profile['activation'] = $key;
     $this->getUsersTable()->save($profile);
     $this->sendMail($email, $key);
     $profile = $this->getUsersTable()->getOneBy(array('profile_name' => $profile['profile_name']));
     $_SESSION['id'] = $profile['id'];
     $_SESSION['profile_name'] = $profile['profile_name'];
     $_SESSION['email'] = $profile['email'];
     $_SESSION['password'] = $profile['password'];
     $this->redirect()->toUrl('/accounts');
 }
Пример #3
0
 public function registrationAction()
 {
     $form = new RegistrationForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         //var_dump($request->getPost());die;
         if ($form->isValid()) {
             $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
             $participant = new Participants();
             $participant->exchangeArray($form->getData());
             //die(print_r($institutions->getPassword()));
             $objectManager->persist($participant);
             $objectManager->flush();
             $message = 'You succesfully registered!';
             $this->flashMessenger()->addMessage($message);
             return $this->redirect()->toRoute('participant');
         } else {
             $message = 'Some error ocured';
             $this->flashMessenger()->addErrorMessage($message);
         }
     }
     return ['form' => $form];
 }