[ 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/ -> admindeletebloguserpermissionsaction.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/dao/users.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   9      lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
  10  
  11      /**
  12       * \ingroup Action
  13       * @private
  14       *
  15       * Revokes the permissions some users might have in a given blog
  16       */
  17      class AdminDeleteBlogUserPermissionsAction extends AdminAction 
  18      {
  19  
  20          var $_userIds;
  21          var $_op;
  22  
  23      	function AdminDeleteBlogUserPermissionsAction( $actionInfo, $request )
  24          {
  25              $this->AdminAction( $actionInfo, $request );
  26              
  27              $this->_op = $actionInfo->getActionParamValue();
  28              if( $this->_op == "deleteBlogUserPermissions" )
  29                  $this->registerFieldValidator( "userId", new IntegerValidator());
  30              else
  31                  $this->registerFieldValidator( "userIds", new ArrayValidator());
  32              $view = new AdminBlogUsersListView( $this->_blogInfo );
  33              $view->setErrorMessage( $this->_locale->tr("error_no_users_selected" ));
  34              $this->setValidationErrorView( $view );
  35          }
  36          
  37  		function perform()
  38          {
  39              if( $this->_op == "deleteBlogUserPermissions" ) {
  40                  $this->_userId = $this->_request->getValue( "userId" );
  41                  $this->_userIds = Array();
  42                  $this->_userIds[] = $this->_userId;
  43              }
  44              else
  45                  $this->_userIds = $this->_request->getValue( "userIds" );
  46                  
  47              // perform the action itself...
  48              $this->_revokePermissions();
  49          }
  50  
  51          function _revokePermissions()
  52          {
  53              // now that we have the list of users we'd like to remove
  54              // let's go through it and remove those that have been selected
  55              $users = new Users();
  56              $userPermissions = new UserPermissions();
  57              $successMessage = "";
  58              $errorMessage = "";
  59              $totalOk = 0;
  60              
  61              $perms = new Permissions();
  62              
  63              foreach( $this->_userIds as $userId ) {
  64                  $res = $userPermissions->revokePermissions( $userId, $this->_blogInfo->getId());
  65                  $userInfo = $users->getUserInfoFromId( $userId );
  66                  if( $res ) {
  67                      $totalOk++;                
  68                      if( $totalOk < 2 )
  69                          $successMessage = $this->_locale->pr("user_removed_from_blog_ok", $userInfo->getUsername());
  70                      else
  71                          $successMessage = $this->_locale->pr("users_removed_from_blog_ok", $totalOk);
  72                  }
  73                  else {
  74                      if( $userInfo )
  75                          $errorMessage .= $this->_locale->pr("error_removing_user_from_blog", $userInfo->getUsername())."<br/>";
  76                      else
  77                          $errorMessage .= $this->_locale->pr("error_removing_user_from_blog2", $userId)."<br/>";
  78                  }
  79              }
  80  
  81              $this->_view = new AdminBlogUsersListView( $this->_blogInfo );
  82              if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
  83              if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );            
  84              $this->setCommonData();
  85  
  86              return true;
  87          }
  88      }
  89  ?>


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