[ 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/action/admin/ -> adminupdateusersettingsaction.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );    
   7      lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/view/admin/adminuserprofileview.class.php" );
   9  
  10      /**
  11       * \ingroup Action
  12       * @private
  13       *
  14       * Action that shows a form to change the settings of the current user.
  15       */
  16      class AdminUpdateUserSettingsAction extends AdminAction 
  17      {
  18  
  19          var $_userPassword;
  20          var $_userConfirmPassword;
  21  
  22          /**
  23           * Constructor. If nothing else, it also has to call the constructor of the parent
  24           * class, BlogAction with the same parameters
  25           */
  26          function AdminUpdateUserSettingsAction( $actionInfo, $request )
  27          {
  28              $this->AdminAction( $actionInfo, $request );
  29              
  30              $this->registerField( "confirmPassword" );
  31              $this->registerField( "userFullName" );
  32              $this->registerFieldValidator( "userEmail", new EmailValidator());
  33              $this->registerFieldValidator( "userPictureId", new IntegerValidator());
  34              $this->registerField( "userAbout" );
  35              $this->registerField( "properties" );
  36              $this->registerField( "userSettingsPassword" );
  37              $view = new AdminUserProfileView( $this->_blogInfo, $this->_userInfo );
  38              $view->setErrorMessage( $this->_locale->tr("error_updating_user_settings"));
  39              $this->setValidationErrorView( $view );
  40          }
  41  
  42          /**
  43           * Validates that the information we've just received from the blog settings
  44           * form is valid... We have to be really sure about this one!!!
  45           */
  46          function validate()
  47          {
  48              // if all correct, we can proceed
  49              $this->_userPassword = trim($this->_request->getValue( "userSettingsPassword" ));
  50              $this->_userConfirmPassword = trim($this->_request->getValue( "confirmPassword" ));
  51              
  52              $valid = parent::validate();        
  53  
  54              // check that the password is correct and confirm it
  55              if( $this->_userPassword != "" ) {
  56                  $passwordVal = new PasswordValidator();
  57                  if( !$passwordVal->validate( $this->_userPassword )) {
  58                      $this->_form->setFieldValidationStatus( "userSettingsPassword", false );                    
  59                      $this->_view = $this->_validationErrorView;
  60                      $this->setCommonData( true );
  61                      return false;
  62                  }
  63                  if( $this->_userPassword != $this->_userConfirmPassword ) {
  64                      $this->_form->setFieldValidationStatus( "confirmPassword", false );
  65                      $this->_view = $this->_validationErrorView;                    
  66                      $this->setCommonData( true );
  67                      return false;
  68                  }
  69              }
  70              
  71              return $valid;
  72          }
  73  
  74          /**
  75           * Carries out the specified action
  76           */
  77          function perform()
  78          {
  79              // update the user information
  80              $this->_userInfo->setEmail( Textfilter::filterAllHTML($this->_request->getValue( "userEmail" )));
  81              if( $this->_userPassword != "" )
  82                  $this->_userInfo->setPassword( $this->_userPassword );
  83              $this->_userInfo->setAboutMyself( Textfilter::filterAllHTML($this->_request->getValue( "userAbout" )));
  84              $this->_userInfo->setFullName( Textfilter::filterAllHTML($this->_request->getValue( "userFullName" )));
  85              $this->_userInfo->setPictureId( $this->_request->getValue( "userPictureId" ));
  86              $this->_userInfo->setProperties( $this->_request->getValue( "properties" ));
  87              $this->notifyEvent( EVENT_PRE_USER_UPDATE, Array( "user" => &$this->_userInfo ));            
  88              $this->_session->setValue( "userInfo", $this->_userInfo );
  89              $this->saveSession();
  90  
  91              // update the user information
  92                 $this->_view =  new AdminUserProfileView( $this->_blogInfo, $this->_userInfo );
  93              $users = new Users();
  94              if( !$users->updateUser( $this->_userInfo ))
  95                  $this->_view->setErrorMessage( $this->_locale->tr("error_updating_user_settings"));
  96              else {
  97                  $this->_view->setSuccessMessage( $this->_locale->pr("user_settings_updated_ok", $this->_userInfo->getUsername()));
  98                  // if everything fine, also say so...
  99                  $this->notifyEvent( EVENT_POST_USER_UPDATE, Array( "user" => &$this->_userInfo ));
 100                  CacheControl::resetBlogCache( $this->_blogInfo->getId());    
 101              }
 102  
 103              $this->setCommonData();
 104  
 105              return true;
 106          }
 107      }
 108  ?>


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