[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/summary/action/ -> dousercreation.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/summary/action/registeraction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/usernamevalidator.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );    
   8      lt_include( PLOG_CLASS_PATH."class/data/filter/htmlfilter.class.php" );
   9      lt_include( PLOG_CLASS_PATH."class/data/filter/htmlspecialcharsfilter.class.php" );
  10  
  11      lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
  12      lt_include( PLOG_CLASS_PATH."class/summary/view/doblogregistrationview.class.php" );
  13      lt_include( PLOG_CLASS_PATH."class/summary/view/summaryusercreationview.class.php" );    
  14  
  15      /**
  16       * starts the user and blog registration process
  17       */
  18      class doUserCreation extends RegisterAction 
  19      {
  20      
  21  		function doUserCreation( $actionInfo, $request )
  22          {
  23              $this->RegisterAction( $actionInfo, $request );
  24              
  25              // apply some filters to the data in the request
  26              $f = new HtmlFilter();
  27              $f->addFilter( new HtmlSpecialCharsFilter());
  28              $this->_request->registerFilter( "userName", $f );
  29              $this->_request->registerFilter( "userFullName", $f );
  30              $this->_request->registerFilter( "userEmail", $f );
  31              $this->_request->registerFilter( "userPassword", $f );
  32              $this->_request->registerFilter( "userPasswordCheck", $f );
  33              
  34              // data validation and stuff like that :)
  35              $this->registerFieldValidator( "userName", new UsernameValidator());
  36              $this->registerFieldValidator( "userPassword", new PasswordValidator());
  37              $this->registerFieldValidator( "userPasswordCheck", new PasswordValidator());
  38              $this->registerFieldValidator( "userEmail", new EmailValidator());
  39              $this->_config =& Config::getConfig();
  40              if( $this->_config->getValue( "use_captcha_auth" )) {
  41                  $this->registerFieldValidator( "userAuth", new StringValidator());
  42              }
  43              $this->registerField( "userFullName" );
  44              $view = new SummaryUserCreationView();
  45              $view->setErrorMessage( $this->_locale->tr("error_adding_user" ));
  46              $this->setValidationErrorView( $view );
  47          }    
  48  
  49          function perform()
  50          {
  51              // if all data is correct, then we can proceed and use it
  52              $this->userName = $this->_request->getValue( "userName" );
  53              $this->userPassword = $this->_request->getValue( "userPassword" );
  54              $this->confirmPassword = $this->_request->getValue( "userPasswordCheck" );
  55              $this->userEmail = $this->_request->getValue( "userEmail" );
  56              $this->userFullName = $this->_request->getValue( "userFullName" );
  57              $this->captcha = $this->_request->getValue( "userAuth" );
  58              
  59              // check if there is already a user with the same username and quit if so
  60              $users = new Users();
  61              if( $users->getUserInfoFromUsername( $this->userName )) {
  62                  $this->_view = new SummaryUserCreationView();
  63                  //$this->_form->hasRun( true );
  64                  $this->_form->setFieldValidationStatus( "userName", false );
  65                  $this->setCommonData( true );
  66                  return false;
  67              }
  68  
  69              // check if this email account has registered and quit if so, but only if the configuration
  70              // says that we should only allow one blog per email account
  71              if( $this->_config->getValue( "force_one_blog_per_email_account" )) {
  72                  if( $users->emailExists($this->userEmail)) {
  73                      $this->_view = new SummaryUserCreationView();
  74                      //$this->_form->hasRun( true );
  75                      $this->_form->setFieldValidationStatus( "userEmail", false );
  76                      $this->setCommonData( true );
  77                      return false;
  78                  }
  79              }
  80              
  81              // check if the passwords match, and stop processing if so too
  82              if( $this->userPassword != $this->confirmPassword ) {
  83                  $this->_view = new SummaryUserCreationView();
  84                  $this->_view->setErrorMessage( $this->_locale->tr("error_passwords_dont_match"));
  85                  $this->_form->setFieldValidationStatus( "userPasswordCheck", false );                
  86                  $this->setCommonData( true );
  87                  return false;
  88              }            
  89              
  90              // check if the captcha matches
  91              if( $this->_config->getValue( "use_captcha_auth")) {
  92                  lt_include( PLOG_CLASS_PATH."class/data/captcha/captcha.class.php" );
  93                  $captcha = new Captcha();
  94                  if( !$captcha->validate( $this->captcha )) {
  95                      $this->_view = new SummaryUserCreationView();
  96                      $this->_view->setErrorMessage( $this->_locale->tr("error_invalid_auth_code"));
  97                      $this->_form->setFieldValidationStatus( "userAuth", false );                
  98                      $this->setCommonData( true );
  99                      return false;                
 100                  }
 101              }
 102  
 103              // save the data to the session
 104              SessionManager::setSessionValue( "userName", $this->userName );
 105              SessionManager::setSessionValue( "userPassword", $this->userPassword );
 106              SessionManager::setSessionValue( "userEmail", $this->userEmail );
 107              SessionManager::setSessionValue( "userFullName", $this->userFullName );
 108  
 109              // if everything went fine, then proceed
 110              $this->_view = new doBlogRegistrationView();
 111              $this->setCommonData();
 112              return true;
 113          }
 114  
 115      }
 116  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics