[ 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/ -> adminupdateresourcealbumaction.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/admineditresourcealbumview.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" );    
   6      lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
   9  
  10      /**
  11       * \ingroup Action
  12       * @private
  13       *
  14       * Shows information about a resource
  15       */
  16      class AdminUpdateResourceAlbumAction extends AdminAction
  17      {
  18  
  19          var $_albumId;
  20          var $_albumName;
  21          var $_albumDescription;
  22          var $_parentId;
  23          var $_showAlbum;
  24  
  25          /**
  26           * Constructor. If nothing else, it also has to call the constructor of the parent
  27           * class, BlogAction with the same parameters
  28           */
  29          function AdminUpdateResourceAlbumAction( $actionInfo, $request )
  30          {
  31              $this->AdminAction( $actionInfo, $request );
  32              
  33              // data validation
  34              $this->registerFieldValidator( "albumId", new IntegerValidator());
  35              $this->registerFieldValidator( "albumName", new StringValidator());
  36              $this->registerFieldValidator( "parentId", new IntegerValidator());
  37              $this->registerField( "albumDescription" );
  38              $this->registerField( "showAlbum" );
  39              $view = new AdminEditResourceAlbumView( $this->_blogInfo );
  40              $view->setErrorMessage( $this->_locale->tr("error_updating_album" ));
  41              $this->setValidationErrorView( $view );
  42              
  43              $this->requirePermission( "update_album" );
  44          }
  45  
  46          /**
  47           * Carries out the specified action
  48           */
  49          function perform()
  50          {
  51              $this->_albumId = $this->_request->getValue( "albumId" );
  52              $this->_parentId = $this->_request->getValue( "parentId" );
  53              $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue( "albumName" ));            
  54              $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue( "albumDescription" ));
  55              $this->_showAlbum = $this->_request->getValue( "showAlbum" );
  56              if( $this->_showAlbum == "" )
  57                  $this->_showAlbum = 0;            
  58          
  59              // fetch the albums for this blog
  60              $albums = new GalleryAlbums();
  61              $album = $albums->getAlbum( $this->_albumId, $this->_blogInfo->getId());
  62              
  63              if( $this->userHasPermission( "view_resources" ))
  64                  $this->_view = new AdminResourcesListView( $this->_blogInfo );
  65              else {
  66                  $this->_view = new AdminEditResourceAlbumView( $this->_blogInfo );
  67                  $this->_view->setValue( "albumName", $this->_albumName );
  68                  $this->_view->setValue( "albumDescription", $this->_albumDescription );
  69                  $this->_view->setValue( "showAlbum", $this->_showAlbum );
  70                  $this->_view->setValue( "parentId", $this->_parentId );
  71                  $this->_view->setValue( "albumId", $this->_albumId );                
  72              }
  73                  
  74              if( !$album ) {
  75                  $this->_view->setErrorMessage( $this->_locale->tr("error_updating_album" ) );
  76                  $this->setCommonData();
  77                  return false;
  78              }
  79              
  80              // update the fields in the object
  81              $album->setName( $this->_albumName );
  82              $album->setDescription( $this->_albumDescription );
  83              $album->setParentId( $this->_parentId );
  84              $album->setShowAlbum( $this->_showAlbum );            
  85              
  86              $this->notifyEvent( EVENT_PRE_ALBUM_UPDATE, Array( "album" => &$album ));
  87              // and update the data in the database
  88              if( !$albums->updateAlbum( $album )) {
  89                  $this->_view->setErrorMessage( $this->_locale->tr("error_updating_album" ) );
  90                  $this->setCommonData();
  91                  return false;
  92              }
  93  
  94              $this->_view->setSuccessMessage( $this->_locale->pr("album_updated_ok", $album->getName()));
  95              $this->notifyEvent( EVENT_POST_ALBUM_UPDATE, Array( "album" => &$album ));            
  96              $this->setCommonData();
  97              
  98              // clear the cache
  99              CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
 100  
 101              // better to return true if everything fine
 102              return true;
 103          }
 104      }
 105  ?>


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