Skip to content

Commit

Permalink
LUT-28236 : prevent blog deletion without archiving it first
Browse files Browse the repository at this point in the history
  • Loading branch information
husel-t committed Jan 8, 2025
1 parent 092f202 commit 0f602f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ diff_blog.latestVersion=Compare the latest versions

message.confirmRemoveBlog=Are you sure that you want to delete this post?
message.confirmRemoveHistoryBlog=Are you sure that you want to delete this version of the post?
message.errorDocumentIsPublished=This post is still published in the site, please unpublish it before delete it.
message.errorDocumentIsActive=This post is still active in the site, please archive it before deleting it.
message.errorTagIsAffected=This Tag is still atached to a post, please detached it before delete it !
message.errorTagExist=This Tag already exist !
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ message.mandatory.searchField=Le champs de recherche est obligatoire !
message.notNumericField=Le champs doit \u00e9tre au format num\u00e9rique !
message.confirmRemoveBlog=Voulez-vous supprimer ce billet ?
message.confirmRemoveHistoryBlog=Voulez-vous supprimer cette version du billet ?
message.errorDocumentIsPublished=Ce billet est encore publi\u00e9 sur le site, pour le supprimer d\u00e9publiez-le !
message.errorDocumentIsActive=Ce billet est encore actif sur le site, pour supprimer ce billet merci d'archiver le billet au pr\u00e9alable.
message.errorTagIsAffected=Ce Tag est est attach\u00e9 \u00e0 un billet, pour le supprimer d\u00e9tachez le !
message.errorTagExist=Ce Tag existe d\u00e9j\a !
Expand Down
11 changes: 7 additions & 4 deletions src/java/fr/paris/lutece/plugins/blog/web/BlogJspBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public class BlogJspBean extends ManageBlogJspBean
private static final String ACCESS_DENIED_MESSAGE = "portal.message.user.accessDenied";
private static final String MESSAGE_CONFIRM_ARCHIVE_BLOG = "blog.message.confirmArchiveBlog";
private static final String MESSAGE_CONFIRM_ARCHIVE_MULTIPLE_BLOGS = "blog.message.confirmArchiveMultipleBlogs";
private static final String MESSAGE_ERROR_DOCUMENT_IS_PUBLISHED = "blog.message.errorDocumentIsPublished";
private static final String MESSAGE_CONFIRM_UNARCHIVE_MULTIPLE_BLOGS = "blog.message.confirmUnarchiveMultipleBlogs";
private static final String MESSAGE_CONFIRM_UNARCHIVE_BLOG= "blog.message.confirmUnarchiveBlog";
private static final String MESSAGE_CONFIRM_REMOVE_MULTIPE_BLOGS = "blog.message.confirmRemoveMultipleBlogs";
Expand Down Expand Up @@ -617,7 +618,7 @@ public String doRemoveHistoryBlog( HttpServletRequest request )
// Inform the user that the blog is currently published and redirect to the blog's history view
UrlItem url = new UrlItem( getViewFullUrl( VIEW_HISTORY_BLOG ) );
url.addParameter( PARAMETER_ID_BLOG, nBlogId );
String strMessageUrl = AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_DOCUMENT_IS_ACTIVE, url.getUrl( ),
String strMessageUrl = AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_DOCUMENT_IS_PUBLISHED, url.getUrl( ),
AdminMessage.TYPE_STOP );
return redirect( request, strMessageUrl );
}
Expand Down Expand Up @@ -945,9 +946,10 @@ public String doRemoveBlog( HttpServletRequest request )

List<BlogPublication> docPublication = BlogPublicationHome.getDocPublicationByIdDoc( nId );

if ( CollectionUtils.isNotEmpty( docPublication ) || BlogHome.findByPrimaryKey( nId ).isArchived() )
if ( CollectionUtils.isNotEmpty( docPublication ) || !BlogHome.findByPrimaryKey( nId ).isArchived( ) )
{
String strMessageUrl = AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_DOCUMENT_IS_ACTIVE, AdminMessage.TYPE_STOP );
UrlItem url = new UrlItem( getActionUrl( VIEW_MANAGE_BLOGS ) );
String strMessageUrl = AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_DOCUMENT_IS_ACTIVE, url.getUrl( ), AdminMessage.TYPE_STOP );

return redirect( request, strMessageUrl );
}
Expand Down Expand Up @@ -1742,7 +1744,8 @@ public String doRemoveMultipleBlog( HttpServletRequest request ) throws AccessDe
}
for ( int docPublicationId : _listSelectedBlogIds )
{
if ( CollectionUtils.isNotEmpty( BlogPublicationHome.getDocPublicationByIdDoc( docPublicationId ) ) )
if ( CollectionUtils.isNotEmpty( BlogPublicationHome.getDocPublicationByIdDoc( docPublicationId ) ) || !BlogHome.findByPrimaryKey(
docPublicationId ).isArchived( ) )
{
String strMessageUrl = AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_DOCUMENT_IS_ACTIVE, AdminMessage.TYPE_STOP );

Expand Down

0 comments on commit 0f602f1

Please sign in to comment.