[ 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/ -> adminupdateuserprofileaction.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/integervalidator.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );    
   6      lt_include( PLOG_CLASS_PATH."class/view/admin/admineditsiteuserview.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/view/admin/adminsiteuserslistview.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );
   9      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );    
  10      lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
  11      lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
  12  
  13      /**
  14       * \ingroup Action
  15       * @private
  16       *
  17       * updates user settings
  18       */
  19      class AdminUpdateUserProfileAction extends AdminAction 
  20      {
  21  
  22          var $_userId;
  23          var $_userPassword;
  24          var $_userEmail;
  25          var $_userAbout;
  26          var $_userFullName;
  27          var $_adminPrivs;
  28          var $_userProperties;
  29  
  30      	function AdminUpdateUserProfileAction( $actionInfo, $request )
  31          {
  32              $this->AdminAction( $actionInfo, $request );
  33              
  34              // data validation
  35              $this->registerField( "userFullName" );
  36              $this->registerFieldValidator( "userEmail", new EmailValidator());
  37              $this->registerFieldValidator( "userPictureId", new IntegerValidator());
  38              $this->registerField( "userAbout" );
  39              $this->registerField( "properties" );
  40              $this->registerField( "userIsSiteAdmin" );
  41              $this->registerField( "userName" );
  42              $this->registerField( "userPermissions" );
  43              $this->registerFieldValidator( "userProfilePassword", new PasswordValidator(), true );
  44              $this->registerFieldValidator( "userStatus", new IntegerValidator());
  45              $view = new AdminEditSiteUserView( $this->_blogInfo );
  46              $view->setErrorMessage( $this->_locale->tr("error_updating_user"));
  47              $this->setValidationErrorView( $view );
  48              
  49              $this->requireAdminPermission( "update_user" );            
  50          }
  51          
  52          function perform()
  53          {
  54              // get the data
  55              $this->_userId = $this->_request->getValue( "userId" );
  56              $this->_userPassword = trim(Textfilter::filterAllHTML($this->_request->getValue( "userProfilePassword" )));
  57              $this->_userEmail = Textfilter::filterAllHTML($this->_request->getValue( "userEmail" ));
  58              $this->_userAbout = Textfilter::filterAllHTML($this->_request->getValue( "userAbout" ));
  59              $this->_userFullName = Textfilter::filterAllHTML($this->_request->getValue( "userFullName" ));
  60              $this->_adminPrivs = $this->_request->getValue( "userIsSiteAdmin" );
  61              $this->_userProperties = $this->_request->getValue( "properties" );
  62              $this->_userStatus = $this->_request->getValue( "userStatus" );
  63              $this->_perms = $this->_request->getValue( "userPermissions" );
  64  
  65              // load the user settings
  66              $users = new Users();
  67              $user  = $users->getUserInfoFromId( $this->_userId );
  68  
  69              // if no info could be fetched, shown an error and quit
  70              if( !$user ) {
  71                  $this->_view = new AdminSiteUsersListView( $this->_blogInfo );
  72                  $this->_view->setErrorMessage( $this->_locale->tr("error_invalid_user") );
  73                  $this->setCommonData();
  74                  return false;
  75              }
  76              
  77              // update the user settings
  78              $user->setEmail( $this->_userEmail );
  79              $user->setAboutMyself( $this->_userAbout );
  80              $user->setSiteAdmin( $this->_adminPrivs );
  81              $user->setFullName( $this->_userFullName );
  82              $user->setProperties( $this->_userProperties );
  83              $user->setStatus( $this->_userStatus );
  84              if( $this->_userPassword != "" )
  85                  $user->setPassword( $this->_userPassword );
  86  
  87              // and finally update the global permissions
  88              // first revoke all permissions
  89              $userPerms = new UserPermissions();
  90              $userPerms->revokePermissions( $user->getId(), 0 );
  91              
  92              // and then assign the new ones
  93              if( is_array( $this->_perms )) {
  94                  foreach( $this->_perms as $val => $permId ) {
  95                      $perm = new UserPermission( $user->getId(), 0, $permId );
  96                      $res = $userPerms->grantPermission( $perm );
  97                  }
  98              }
  99                  
 100              $this->notifyEvent( EVENT_PRE_USER_UPDATE, Array( "user" => &$user ));
 101  
 102              // and now update them
 103              if( !$users->updateUser( $user )) {
 104                  $this->_view =  new AdminSiteUsersListView( $this->_blogInfo );
 105                  $this->_view->setErrorMessage( $this->_locale->tr("error_updating_user") );
 106                  $this->setCommonData();
 107                  return false;
 108              }
 109              
 110              // the post-update event... if needed
 111              $this->notifyEvent( EVENT_POST_USER_UPDATE, Array( "user" => &$user ));            
 112  
 113              $this->_view = new AdminSiteUsersListView( $this->_blogInfo );
 114              $this->_view->setSuccessMessage( $this->_locale->pr("user_updated_ok", $user->getUsername()));
 115              $this->setCommonData();
 116  
 117              return true;
 118          }
 119      }
 120  ?>


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