[ 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/ -> adminupdatebloguseraction.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/view/admin/adminbloguserslistview.class.php" );    
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );    
   6      lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );    
   8  
   9      /**
  10       * \ingroup Action
  11       * @private
  12       */
  13      class AdminUpdateBlogUserAction extends AdminAction 
  14      {    
  15          /**
  16           * Constructor. If nothing else, it also has to call the constructor of the parent
  17           * class, BlogAction with the same parameters
  18           */
  19          function AdminUpdateBlogUserAction( $actionInfo, $request )
  20          {
  21              $this->AdminAction( $actionInfo, $request );
  22              
  23              // register one validator
  24              $this->registerFieldValidator( "userId", new IntegerValidator());
  25              // and the view we should show in case there is a validation error
  26              $errorView = new AdminBlogUsersListView( $this->_blogInfo );
  27              $errorView->setErrorMessage( $this->_locale->tr("error_invalid_user_id" ));            
  28              $this->setValidationErrorView( $errorView );
  29              
  30              $this->requirePermission( "update_blog_user");
  31          }
  32  
  33          /**
  34           * Carries out the specified action
  35           */
  36          function perform()
  37          {
  38              // fetch the data, we already know it's valid and that we can trust it!
  39              $userId = $this->_request->getValue( "userId" );
  40              $this->_perms = $this->_request->getValue( "perm" );            
  41              
  42              // load the user
  43              $users = new Users();
  44              $userInfo = $users->getUserInfoFromId( $userId );
  45              if( !$userInfo ) {
  46                  $errorView = new AdminBlogUsersListView( $this->_blogInfo );
  47                  $errorView->setErrorMessage( $this->_locale->tr("error_invalid_user_id" ));
  48                  $this->setCommonData();
  49                  return( false );
  50              }
  51              
  52              $this->notifyEvent( EVENT_PRE_USER_UPDATE, Array( "user" => &$user ));            
  53              
  54              // first revoke all permissions
  55              $userPerms = new UserPermissions();
  56              $userPerms->revokePermissions( $userInfo->getId(), $this->_blogInfo->getId());
  57              
  58              // and then assign the new ones
  59              if( is_array( $this->_perms )) {
  60                  foreach( $this->_perms as $val => $permId ) {
  61                      $perm = new UserPermission( $userInfo->getId(), $this->_blogInfo->getId(), $permId );
  62                      $res = $userPerms->grantPermission( $perm );
  63                  }
  64              }
  65              
  66              $this->notifyEvent( EVENT_POST_USER_UPDATE, Array( "user" => &$user ));            
  67              
  68              $this->_view = new AdminBlogUsersListView( $this->_blogInfo );
  69              $this->_view->setSuccessMessage( $this->_locale->pr("user_permissions_updated_ok", $userInfo->getUsername()));
  70              $this->setCommonData();            
  71              
  72              return( true );
  73          }
  74      }
  75  ?>


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