00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/view/admin/adminnewalbumview.class.php" );
00005 lt_include( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" );
00006 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
00007 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
00008 lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
00009 lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
00010 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
00011
00018 class AdminAddResourceAlbumAction extends AdminAction
00019 {
00020
00021 var $_albumName;
00022 var $_albumDescription;
00023 var $_parentId;
00024
00029 function AdminAddResourceAlbumAction( $actionInfo, $request )
00030 {
00031 $this->AdminAction( $actionInfo, $request );
00032
00033
00034 $this->registerFieldValidator( "albumName", new StringValidator());
00035 $this->registerFieldValidator( "parentId", new IntegerValidator());
00036 $this->registerFieldValidator( "albumDescription", new StringValidator(), true);
00037 $this->setValidationErrorView( new AdminNewAlbumView( $this->_blogInfo ));
00038
00039 $this->requirePermission( "add_album" );
00040 }
00041
00045 function perform()
00046 {
00047
00048 $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue( "albumName" ));
00049 $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue( "albumDescription" ));
00050 $this->_parentId = $this->_request->getValue( "parentId" );
00051 $showAlbum = $this->_request->getValue("showAlbum") ? 1 : 0;
00052
00053
00054 $albums = new GalleryAlbums();
00055 $t = new Timestamp();
00056 $album = new GalleryAlbum( $this->_blogInfo->getId(), $this->_albumName,
00057 $this->_albumDescription,
00058 GALLERY_RESOURCE_PREVIEW_AVAILABLE,
00059 $this->_parentId,
00060 $t->getTimestamp(),
00061 Array(),
00062 $showAlbum);
00063
00064 $this->notifyEvent( EVENT_PRE_ALBUM_ADD, Array( "album" => &$album ));
00065
00066 $result = $albums->addAlbum( $album );
00067
00068 if( $this->userHasPermission( "view_resources" ))
00069 $this->_view = new AdminResourcesListView( $this->_blogInfo, Array( "albumId" => $this->_parentId, "gotoLastPage" => true ));
00070 else
00071 $this->_view = new AdminNewAlbumView( $this->_blogInfo );
00072
00073 if( $result ) {
00074 $this->_view->setSuccessMessage( $this->_locale->pr( "album_added_ok", $album->getName()));
00075 $this->notifyEvent( EVENT_POST_ALBUM_ADD, Array( "album" => &$album ));
00076
00077 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
00078 }
00079 else {
00080 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_album" ) );
00081 }
00082 $this->setCommonData();
00083
00084
00085 return true;
00086 }
00087 }
00088 ?>