public function registrationAction()
 {
     // Only for administrators
     if (!$this->getUser() || !$this->getUser()->isAdmin()) {
         // Redirects
         $this->_helper->redirector->gotoRoute(array('controller' => 'admin', 'action' => 'login'), 'default', true);
         return;
     }
     $this->view->title = 'Registrace administrátora';
     $form = new RegistrationForm();
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $formValues = $form->getValues();
             if ($formValues["heslo"] != $formValues["heslo2"]) {
                 //todo barevne zvyrazeni chybnych poli + kontrola formatu
                 //neni stejne heslo
             } else {
                 //pokud už uživatel není v databázi
                 $formValues["heslo"] = sha1("interview" . $formValues["heslo"]);
                 $user = My_Model::get('Users')->createRow();
                 $user->updateFromArray($formValues);
                 $this->_helper->redirector->gotoRoute(array('controller' => 'candidate', 'action' => 'index'), 'default', true);
             }
         }
     }
     $this->view->registrationform = $form;
 }
예제 #2
0
 public function indexxAction()
 {
     $loEntityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $loUser = new Access();
     $loForm = new RegistrationForm();
     $loForm->get('submit')->setValue('Register');
     $loForm->setHydrator(new DoctrineHydrator($loEntityManager, 'Access\\Entity\\Access'));
     if ($this->requestIsPost()) {
         $loForm->setInputFilter(new RegistrationFilter($this->getServiceLocator()));
         $loForm->setData($this->requestPost());
         if ($loForm->isValid()) {
             $poUser->set('stPasswordSalt', String::generateDynamicSalt());
             $poUser->set('UserGroup_Id', null);
             $poUser->set('stRegistrationToken', md5(uniqid(mt_rand(), true)));
             $loUser->populate($loForm->getData());
             $this->sendConfirmationEmail($loUser);
             $this->flashMessenger()->addMessage(array('id' => $this->get('_sModule') . '-' . microtime(true), 'hidden' => $this->get('_bHiddenPushMessage'), 'push' => $this->get('_bPushMessage'), 'type' => 'success', $loUser->getEmail()));
             $loEntityManager->persist($loUser);
             $loEntityManager->flush();
         }
     }
     return new ViewModel(array('form' => $loForm));
 }