[ 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/ -> adminaddresourcealbumaction.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/adminnewalbumview.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.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/gallery/dao/galleryalbums.class.php" );
   9      lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
  10      lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
  11  
  12      /**
  13       * \ingroup Action
  14       * @private
  15       *
  16       * Adds a new album
  17       */
  18      class AdminAddResourceAlbumAction extends AdminAction
  19      {
  20  
  21          var $_albumName;
  22          var $_albumDescription;
  23          var $_parentId;
  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 AdminAddResourceAlbumAction( $actionInfo, $request )
  30          {
  31              $this->AdminAction( $actionInfo, $request );
  32              
  33              // validation stuff
  34              $this->registerFieldValidator( "albumName", new StringValidator());
  35              $this->registerFieldValidator( "parentId", new IntegerValidator());
  36              $this->_form->registerField( "albumDescription" );
  37              $this->setValidationErrorView( new AdminNewAlbumView( $this->_blogInfo ));
  38              
  39              $this->requirePermission( "add_album" );
  40          }
  41  
  42          /**
  43           * Carries out the specified action
  44           */
  45          function perform()
  46          {
  47              // fetch our data
  48              $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue( "albumName" ));
  49              $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue( "albumDescription" ));
  50              $this->_parentId = $this->_request->getValue( "parentId" );            
  51              $showAlbum = $this->_request->getValue("showAlbum") ? 1 : 0;
  52              
  53              // create the album
  54              $albums = new GalleryAlbums();
  55              $t = new Timestamp();
  56              $album = new GalleryAlbum( $this->_blogInfo->getId(), $this->_albumName, 
  57                                         $this->_albumDescription, 
  58                                         GALLERY_RESOURCE_PREVIEW_AVAILABLE,
  59                                         $this->_parentId, 
  60                                         $t->getTimestamp(),
  61                                         Array(),
  62                                         $showAlbum);
  63                                         
  64              $this->notifyEvent( EVENT_PRE_ALBUM_ADD, Array( "album" => &$album ));
  65              // and add it to the database
  66              $result = $albums->addAlbum( $album );
  67              
  68              if( $this->userHasPermission( "view_resources" ))
  69                     $this->_view = new AdminResourcesListView( $this->_blogInfo, Array( "albumId" => $this->_parentId ));
  70                 else
  71                     $this->_view = new AdminNewAlbumView( $this->_blogInfo );
  72                 
  73              if( $result ) {
  74                  $this->_view->setSuccessMessage( $this->_locale->pr( "album_added_ok", $album->getName()));
  75                  $this->notifyEvent( EVENT_POST_ALBUM_ADD, Array( "album" => &$album ));                                
  76                  // clear the cache if everything went fine
  77                  CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
  78              }
  79              else {
  80                  $this->_view->setErrorMessage( $this->_locale->tr("error_adding_album" ) );
  81              }
  82              $this->setCommonData();
  83  
  84              // better to return true if everything fine
  85              return true;
  86          }
  87      }
  88  ?>


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