[ 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/ -> adminupdatepermissionaction.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/admintemplatedview.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/view/admin/adminpermissionslistview.class.php" );    
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );    
   7      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );        
   8      lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" );    
   9  
  10      /**

  11       * \ingroup Action

  12       * @private

  13        *

  14        * Updates an existing permission in the database

  15       */
  16      class AdminUpdatePermissionAction extends AdminAction 
  17      {
  18  		function AdminUpdatePermissionAction( $actionInfo, $request )
  19          {
  20              $this->AdminAction( $actionInfo, $request );
  21              
  22              // register two validators

  23              $this->registerFieldValidator( "permissionName", new StringValidator());
  24              $this->registerFieldValidator( "permissionDescription", new StringValidator());
  25              $this->registerFieldValidator( "permissionId", new IntegerValidator());
  26              $this->registerField( "corePermission" );
  27              $this->registerField( "adminOnlyPermission" );            
  28              // and the view we should show in case there is a validation error

  29              $errorView = new AdminTemplatedView( $this->_blogInfo, "editpermission" );
  30              $errorView->setErrorMessage( $this->_locale->tr("error_updating_permission" ));            
  31              $this->setValidationErrorView( $errorView );
  32              
  33              $this->requireAdminPermission( "update_permission" );            
  34          }
  35          
  36          function perform()
  37          {
  38              // load the permission            

  39              $perms = new Permissions();
  40              $perm = $perms->getPermission( $this->_request->getValue( "permissionId" ));
  41              
  42              if( !$perm ) {
  43                  $this->_view = new AdminPermissionsListView( $this->_blogInfo );
  44                  $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_permission" ));            
  45                  $this->setCommonData();
  46                  return( false );
  47              }
  48              
  49              $perm->setName( $this->_request->getValue( "permissionName" ));            
  50              $perm->setDescription( $this->_request->getValue( "permissionDescription" ));
  51              $perm->setCorePermission(( $this->_request->getValue( "corePermission" ) == "" ? false : true ));
  52              $perm->setAdminOnlyPermission(( $this->_request->getValue( "adminOnlyPermission" ) == "" ? false : true ));
  53              
  54              if( $perms->updatePermission( $perm )) {
  55                  $this->_view = new AdminPermissionsListView( $this->_blogInfo );
  56                  $this->_view->setSuccessMessage( $this->_locale->tr("permission_updated_ok" ));
  57                  $this->setCommonData();
  58              }
  59              else {
  60                  $this->_view->setErrorMessage( $this->_locale->tr("error_updating_permission" ));
  61                  $this->_view->setError( true );
  62                  $this->setCommonData( true );
  63              }
  64          }
  65      }
  66  ?>


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