コード例 #1
0
ファイル: SignupController.php プロジェクト: rindPHI/ProSecCo
 public function insertDataAction()
 {
     $this->initForm();
     $request = $this->getRequest();
     if ($this->getRequest()->isPost()) {
         if ($this->form->isValid($request->getPost())) {
             $userData = new Application_Model_UserComplete($this->form->getValues());
             $mapper = new Application_Model_UserCompleteMapper();
             $mapper->save($userData);
             Prosecco_Authentication::getInstance()->authenticate($userData->__get('Uname'), $userData->__get('Password'));
             return $this->_helper->redirector('create-keys');
         }
     }
     $this->view->form = $this->form;
 }
コード例 #2
0
 public function signupAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     if ($this->getRequest()->isPost()) {
         $signupForm = new Application_Form_Signup();
         if ($signupForm->isValid($this->getRequest()->getParams())) {
             //save new user
             $user = new Application_Model_Models_User($signupForm->getValues());
             $user->registerObserver(new Tools_Mail_Watchdog(array('trigger' => Tools_Mail_SystemMailWatchdog::TRIGGER_SIGNUP)));
             $user->setRoleId(Tools_Security_Acl::ROLE_MEMBER);
             if (isset($this->_helper->session->refererUrl)) {
                 $user->setReferer($this->_helper->session->refererUrl);
             }
             $signupResult = Application_Model_Mappers_UserMapper::getInstance()->save($user);
             if (!$user->getId()) {
                 $user->setId($signupResult);
             }
             //send mails by notifying mail observer about successful sign-up,
             $user->notifyObservers();
             //redirect to signup landing page
             $signupLandingPage = Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_SIGNUPLAND);
             if ($signupLandingPage instanceof Application_Model_Models_Page) {
                 $this->_redirect($this->_helper->website->getUrl() . $signupLandingPage->getUrl());
                 exit;
             } else {
                 $this->_redirect($this->_helper->website->getUrl());
             }
         } else {
             $this->_helper->flashMessenger->addMessage(Tools_Content_Tools::proccessFormMessagesIntoHtml($signupForm->getMessages(), get_class($signupForm)));
             $signupPageUrl = $this->_helper->session->signupPageUrl;
             unset($this->_helper->session->signupPageUrl);
             $this->_redirect($this->_helper->website->getUrl() . ($signupPageUrl ? $signupPageUrl : ''));
         }
     }
 }
コード例 #3
0
 public function editAction()
 {
     $request = $this->getRequest();
     $authns = new Zend_Session_Namespace('AuthNameSpace');
     if (!isset($authns->userId)) {
         return;
     }
     $form = new Application_Form_Signup();
     $mapper = new Application_Model_MemberMapper();
     $member = new Application_Model_Member();
     $mapper->find($authns->userId, $member);
     //reuse member_id in post
     $id = $member->getId();
     //handle changes to member info
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             //get the newly updated form value
             $member = new Application_Model_Member($form->getValues());
             //set the id of the form in order to make changes to the same member in database
             $member->setId($id);
             //Verify user password before updating user information
             $oldPassword = $form->getValue('oldPassword');
             if ($mapper->verifyPassword($member, $oldPassword)) {
                 $mapper->save($member);
                 $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Update Successful!');
                 $this->_logger->log('Update: Password Verified!', Zend_Log::INFO);
                 return $this->_redirect('/');
             } else {
                 $this->_helper->FlashMessenger()->setNamespace('error')->addMessage('Incorrect password. Failed to save changes.');
                 $this->_logger->log('Update: Incorrect Password!', Zend_Log::INFO);
                 return $this->_redirect('/members/edit');
             }
         }
     }
     //form data array to populate signup form with existing data
     $data = array('memberLogin' => $member->getMemberLogin(), 'memberPassword' => $member->getMemberPassword(), 'firstName' => $member->getFirstName(), 'lastName' => $member->getLastName(), 'email' => $member->getEmail());
     $form->populate($data);
     $this->view->form = $form;
 }