[ 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/ -> admindeleteresourceaction.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/adminresourceslistview.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresource.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   9  
  10      /**
  11       * \ingroup Action
  12       * @private
  13       *
  14       * Deletes a resource from the blog
  15       */
  16      class AdminDeleteResourceAction extends AdminAction
  17      {
  18  
  19          var $_resourceIds;
  20  
  21          /**
  22           * Constructor. If nothing else, it also has to call the constructor of the parent
  23           * class, BlogAction with the same parameters
  24           */
  25          function AdminDeleteResourceAction( $actionInfo, $request )
  26          {
  27              $this->AdminAction( $actionInfo, $request );
  28              
  29              // data validation
  30              $this->registerFieldValidator( "resourceId", new IntegerValidator());
  31              $view = new AdminResourcesListView( $this->_blogInfo );
  32              $view->setErrorMessage( $this->_locale->tr("error_no_resources_selected"));
  33              $this->setValidationErrorView( $view );
  34          }
  35  
  36          /**
  37           * Carries out the specified action
  38           */
  39          function perform()
  40          {
  41              // load the resource
  42              $resourceId = $this->_request->getValue( "resourceId" );
  43              $resources = new GalleryResources();
  44              
  45              // initialize the view we're going to use
  46              $this->_view = new AdminResourcesListView( $this->_blogInfo );
  47  
  48                 // fetch the resource first, to get some info about it
  49              $resource = $resources->getResource( $resourceId, $this->_blogInfo->getId());
  50              if( !$resource ) {
  51                  $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_resource" ));
  52                  $this->setCommonData();
  53                  return false;
  54              }
  55              
  56              // if the resource was loaded ok...
  57              $this->notifyEvent( EVENT_PRE_RESOURCE_DELETE, Array( "resource" => &$resource ));
  58              
  59              // remove it
  60                 $res = $resources->deleteResource( $resourceId, $this->_blogInfo->getId());
  61              if( $res ) {
  62                  $this->_view->setSuccessMessage( $this->_locale->pr("resource_deleted_ok", $resource->getFileName()));
  63                  $this->notifyEvent( EVENT_PRE_RESOURCE_DELETE, Array( "resource" => &$resource ));
  64  
  65                  // clear the cache if everything went fine
  66                  CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
  67              }
  68              else 
  69                  $this->_view->setErrorMessage( $this->_locale->pr("error_deleting_resource", $resource->getFileName()));
  70  
  71              // return the view
  72              $this->setCommonData();
  73              
  74              // better to return true if everything fine
  75              return true;
  76          }
  77      }
  78  ?>


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