[ Index ] |
|
Code source de LifeType 1.2.4 |
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/data/validator/integervalidator.class.php" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 * 13 * Deletes a resource from the blog 14 */ 15 class AdminDeleteResourceAlbumAction extends AdminAction 16 { 17 18 var $_albumIds; 19 20 /** 21 * Constructor. If nothing else, it also has to call the constructor of the parent 22 * class, BlogAction with the same parameters 23 */ 24 function AdminDeleteResourceAlbumAction( $actionInfo, $request ) 25 { 26 $this->AdminAction( $actionInfo, $request ); 27 28 $this->registerFieldValidator( "albumId", new IntegerValidator()); 29 $view = new AdminResourcesListView( $this->_blogInfo ); 30 $view->setErrorMessage( $this->_locale->tr("error_no_resources_selected")); 31 $this->setValidationErrorView( $view ); 32 } 33 34 /** 35 * carries out the specified album 36 */ 37 function perform() 38 { 39 // get the album id 40 $albumId = $this->_request->getValue( "albumId" ); 41 42 // load the resource 43 $albums = new GalleryAlbums(); 44 45 // create the view 46 $this->_view = new AdminResourcesListView( $this->_blogInfo ); 47 48 // fetch the resource albumm first, to get some info about it 49 $album = $albums->getAlbum( $albumId, $this->_blogInfo->getId(), false ); 50 if( !$album ) { 51 $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_album" )); 52 $this->setCommonData(); 53 return false; 54 } 55 56 // notify of the "pre" delete event 57 $this->notifyEvent( EVENT_PRE_ALBUM_DELETE, Array( "album" => &$album )); 58 59 // 60 // this album cannot be deleted if either: 61 // 1) we have resources under it 62 // 2) we have child albums under it 63 // 64 if( $album->getNumChildren() > 0 || $album->getNumResources() > 0 ) { 65 $this->_view->setErrorMessage( $this->_locale->pr("error_album_has_children", $album->getName())); 66 } 67 else { 68 // otherwise, we can go ahead and remove it 69 if( $albums->deleteAlbum( $albumId, $this->_blogInfo->getId())) { 70 $this->_view->setSuccessMessage( $this->_locale->pr("album_deleted_ok", $album->getName())); 71 $this->notifyEvent( EVENT_PRE_ALBUM_DELETE, Array( "album" => &$album )); 72 // clear the cache 73 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false ); 74 } 75 else { 76 $this->_view->setErrorMessage( $this->_locale->pr("error_deleting_album", $album->getName())); 77 } 78 } 79 80 // return the view 81 $this->setCommonData(); 82 83 // better to return true if everything fine 84 return true; 85 } 86 } 87 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |