예제 #1
0
 /**
  * @param Application_Model_Entity_User $user
  * @return string
  */
 public function signUp(Application_Model_Entity_User $user, $notify, $code = null)
 {
     $language = 'en';
     try {
         $locale = new Zend_Locale(Zend_Locale::BROWSER);
         $language = $locale->getLanguage();
         if ($language !== 'de') {
             $language = 'en';
         }
     } catch (Exception $e) {
     }
     $this->_db->insert($this->_table, ['firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'email' => $user->getEmail(), 'password' => $user->getPassword(), 'language' => $language, 'notify' => $notify, 'date' => new Zend_Db_Expr('NOW()'), 'code' => $code]);
     // get the user's id
     $user->setId($this->_db->lastInsertId($this->_table));
     // insert a dataset with the validation code to the validation table
     return Application_Model_ValidationRepository::getInstance()->addValidation($user);
 }
예제 #2
0
 public function validationAction()
 {
     $this->_helper->layout->setLayout('entrance');
     $request = $this->getRequest();
     $form = new Application_Form_UserValidation();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             if (Application_Model_ValidationRepository::getInstance()->validateCode($form->getValue('code'))) {
                 $this->_session->clearSession();
                 echo '<div class="center">' . $this->_translate->_('validation_success') . '</div>';
                 return;
             } else {
                 $form->getElement('code')->addError($this->_translate->_('validation_invalid'));
             }
         }
     } else {
         if (!is_null($this->getParam('code'))) {
             if (Application_Model_ValidationRepository::getInstance()->validateCode($this->getParam('code'))) {
                 $this->_session->clearSession();
                 echo '<div class="center">' . $this->_translate->_('validation_success') . '</div>';
                 return;
             } else {
                 $form->getElement('code')->addError($this->_translate->_('validation_invalid'));
             }
         }
     }
     $this->view->form = $form;
 }