/**
  * indexAction
  *
  * Default registration action
  * 
  * @return void
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     if ($request->isPost() && $this->_form->isValid($request->getPost())) {
         $service = $this->_serviceFactory->get('Registration');
         $user = $service->registerAccount($this->_form->getValues());
         if ($user instanceof \Orm\Entity\User) {
             $this->_redirect('/tickets/');
         } else {
             throw new \Exception('Failed to register a valid user account');
         }
     }
     $this->view->form = $this->_form;
 }
Exemplo n.º 2
0
 public function registerAction()
 {
     // action body
     $request = $this->getRequest();
     $form = new Application_Form_Registration();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $userMapper = new Application_Model_UserMapper();
             $user = new Application_Model_User($form->getValues());
             $id = $userMapper->save($user);
             $user->setId($id);
             $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . "/../tmp/log.txt");
             $logger = new Zend_Log($writer);
             try {
                 $this->sendConfirmationEmail($user);
                 $logger->log("Email confirmation sent.", Zend_Log::INFO);
             } catch (Exception $e) {
                 // Log error on production
                 $logger->log("Email confirmation failed." . $e->getMessage(), Zend_Log::EMERG);
             }
             $form = null;
             $request->clearParams();
             $this->view->msg = 'An email with a confirmation link has been sent to your email. Please use the link to complete your registration.';
         }
     }
     $this->view->form = $form;
 }
Exemplo n.º 3
0
 public function roAction()
 {
     $this->view->form = $form = new Application_Form_Registration('ro');
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             Registration::saveRegistration($form->getValues(), 'ro');
             $this->_redirect('index/rothanks');
         } else {
             $form->populate($formData);
         }
     }
 }
Exemplo n.º 4
0
 public function indexAction()
 {
     //$db	= Zend_Db_Table_Abstract::getDefaultAdapter();
     $registerForm = new Application_Form_Registration($_POST);
     if ($this->getRequest()->isPost()) {
         $this->request = $this->getRequest();
         if (isset($_POST['rbutton']) && $registerForm->isValid($_POST)) {
             $db = Zend_Registry::get('dbc');
             $db->query('SET NAMES utf8;');
             /*
                 			$adapter = new Zend_Auth_Adapter_DbTable(
                 					$db,
                 					'users',
                 					'name',
                 					'password'
                 			);
                 	
                 			$adapter->setIdentity($registerForm->getValue('username'));
                 			$adapter->setCredential($registerForm->getValue('passwor2'));
                 	
                 			$result = $adapter->authenticate($adapter);
                 	
                 			if (User nicht vorhanden) {
             */
             $values = $registerForm->getValues();
             if ($registerForm->getValue('password1') != $registerForm->getValue('password2')) {
                 $success = -1;
                 $this->view->success = $success;
                 //$this->redirect('registration');
             } else {
                 $db->query('SET NAMES utf8;');
                 $stmt = $db->prepare('	INSERT INTO `users`(`name`, `password`, `userstate`) 
 											VALUES ("' . mysql_real_escape_string($registerForm->getValue('username')) . '",
 													"' . mysql_real_escape_string($registerForm->getValue('password2')) . '", 92)	
 									');
                 $stmt->execute();
                 $success = 1;
                 $this->view->success = $success;
                 $this->redirect('index');
                 return;
             }
         }
     }
     $this->view->registerForm = $registerForm;
 }
Exemplo n.º 5
0
 public function editAction()
 {
     $storage = new Zend_Auth_Storage_Session();
     $data = $storage->read();
     if (!$data) {
         $this->_redirect('auth/login');
     }
     $form = new Application_Form_Registration();
     $this->view->form = $form;
     $id = $this->getRequest()->getParam('id');
     $model = new Application_Model_User();
     $form_data = $model->getUserById($id)->toArray();
     $form->populate($form_data[0]);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             $data_to_edit = $form->getValues();
             $user = new Application_Model_User();
             unset($data_to_edit['confirmPassword']);
             $edit = $user->editUser($this->getRequest()->getParam('id'), $data_to_edit);
             $this->redirect('auth/login');
         }
     }
 }