Esempio n. 1
0
 /**
  * The public registration action - display registration form and register
  *
  * @return void
  */
 public function registrationAction()
 {
     $registrationForm = new User_Form();
     $registrationForm->setAction($this->baseUrl . '/' . Digitalus_Toolbox_Page::getCurrentPageName() . '/p/a/registration');
     $registrationForm->getElement('name')->addValidators(array(array('UsernameExistsNot', true)));
     $registrationForm->onlyRegistrationActionElements(array('legend' => 'Register'));
     // show form if unsent or invalid
     if (!$this->_request->isPost() || !$registrationForm->isValid($_POST)) {
         $this->view->form = $registrationForm;
     } else {
         $mdlUser = new Model_User();
         $mdlRegistration = new Login_Registration();
         $mdlPassword = new Login_Password();
         $password = $mdlPassword->getRandomPassword();
         $userName = Digitalus_Filter_Post::get('name');
         $firstName = Digitalus_Filter_Post::get('first_name');
         $lastName = Digitalus_Filter_Post::get('last_name');
         $email = Digitalus_Filter_Post::get('email');
         $success = false;
         if ($mdlRegistration->createUser($userName, $firstName, $lastName, $email, $password, 0, $this->moduleData->aclRole)) {
             if ($mdlRegistration->sendConfirmationMail($userName, $email, $this->moduleData->email)) {
                 $success = true;
             }
         }
         $this->view->userName = $userName;
         $this->view->email = $email;
         $this->view->password = $password;
         $this->view->success = $success;
         unset($password);
     }
 }