Exemple #1
0
 private function createUser($username, $raw_password)
 {
     $userinfo = array('username' => $username, 'password' => coreContext::getInstance()->getUser()->getSaltyHashedPassword($raw_password), 'userlevel' => $this->getOption('level', UsersPeer::USERLEVEL_USER), 'email' => trim($this->getOption('email', 'created@localhost')), 'location' => trim($this->getOption('location', 'localhost')));
     //die(print_r($userinfo, true));
     if (false === UsersPeer::createUser($userinfo)) {
         $this->throwError('Could not create user.');
     }
 }
Exemple #2
0
 /**
  * Create a new account.
  * 
  * @return 
  */
 public function executeCreate($request)
 {
     if ($request->getMethod() != coreRequest::POST) {
         // setup form
         // development
         /*
               if (CORE_ENVIRONMENT==='dev')
               {
                 $request->getParameterHolder()->add(array(
                   'username' => '...' . rand(1,1000),
                   'email' => '...',
                   'password'=>'xxxxx',
                   'password2'=>'xxxxx',
                   'location'=>'Foo Bar')
                 );
               }*/
     } else {
         $validator = new coreValidator($this->getActionName());
         if ($validator->validate($request->getParameterHolder()->getAll())) {
             $this->username = trim($request->getParameter('username'));
             $raw_password = trim($request->getParameter('password'));
             if (UsersPeer::usernameExists($this->username)) {
                 $request->setError('username_duplicate', 'Sorry, that username is already taken, please pick another one.');
                 return coreView::SUCCESS;
             }
             $userinfo = array('username' => trim($request->getParameter('username')), 'password' => $this->getUser()->getSaltyHashedPassword($raw_password), 'email' => trim($request->getParameter('email')), 'location' => trim($request->getParameter('location', '')));
             // username is available, create user
             UsersPeer::createUser($userinfo);
             // create user on the PunBB forum with same username and password
             // NOT IN STAGING -- staging does not have a "test" forum database
             if (coreContext::getInstance()->getConfiguration()->getEnvironment() !== 'staging' && coreConfig::get('app_path_to_punbb') !== null) {
                 try {
                     $forumAccountSuccess = PunBBUsersPeer::createAccount($userinfo);
                 } catch (coreException $e) {
                     $forumAccountSuccess = false;
                 }
                 if (!$forumAccountSuccess) {
                     $url = $this->getController()->genUrl('@contact');
                     $request->setError('forum_account', 'Oops, there was a problem while accessing the forum database.<br/>' . 'Please <a href="' . $url . '">contact the webmaster</a> with your username and password,<br/>' . 'and we will create your forum account as soon as possible.');
                 }
             } else {
                 // STAGING
                 $forumAccountSuccess = false;
                 $request->setError('forum_account', '(Forum account NOT created in test environment)');
             }
             // send email confirmation
             $mailer = new rtkMail();
             $mailer->sendNewAccountConfirmation($userinfo['email'], $userinfo['username'], $raw_password);
             return 'Done';
         }
     }
 }