Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/java/fr/paris/lutece/plugins/blog/web/BlogJspBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public String doAddTag( HttpServletRequest request )
return JsonUtil.buildJsonResponse( new JsonResponse( RESPONSE_BLOG_LOCKED ) );
}

if ( RBACService.isAuthorized( Tag.PROPERTY_RESOURCE_TYPE, strIdTag, Tag.PERMISSION_CREATE, getUser( ) ) )
if ( RBACService.isAuthorized( Tag.PROPERTY_RESOURCE_TYPE, strIdTag, Tag.PERMISSION_CREATE, getUser( ) == null ? AdminUserService.getAdminUser( request ) : getUser()) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this fix for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these modifications take into account the evolution requested in the ticket 99710 : improvement of the creation of tickets on O2T

{

String strTagName = request.getParameter( PARAMETER_TAG_NAME );
Expand Down Expand Up @@ -571,7 +571,7 @@ public String doRemoveTag( HttpServletRequest request )
return JsonUtil.buildJsonResponse( new JsonResponse( RESPONSE_BLOG_LOCKED ) );
}

if ( RBACService.isAuthorized( Tag.PROPERTY_RESOURCE_TYPE, strIdTag, Tag.PERMISSION_DELETE, getUser( ) ) )
if ( RBACService.isAuthorized( Tag.PROPERTY_RESOURCE_TYPE, strIdTag, Tag.PERMISSION_DELETE, getUser( ) == null ? AdminUserService.getAdminUser( request ) : getUser() ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this fix for?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please create a jira for describing the functionality you want to add and do the PR with the jira number?

{
Tag tag = _blog.getTag( ).stream( ).filter( tg -> tg.getIdTag( ) == Integer.parseInt( strIdTag ) ).collect( Collectors.toList( ) ).get( 0 );
_blog.deleteTag( tag );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import fr.paris.lutece.portal.util.mvc.commons.annotations.View;
import fr.paris.lutece.util.ReferenceItem;
import fr.paris.lutece.util.html.HtmlTemplate;
import fr.paris.lutece.api.user.User;

/**
* This class provides the user interface to manage HtmlDoc features ( manage, create, modify, remove )
Expand Down
1 change: 0 additions & 1 deletion src/java/fr/paris/lutece/plugins/blog/web/TagJspBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
*/
package fr.paris.lutece.plugins.blog.web;

import fr.paris.lutece.api.user.User;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@

import fr.paris.lutece.plugins.blog.business.Blog;
import fr.paris.lutece.plugins.blog.business.BlogHome;
import fr.paris.lutece.plugins.blog.business.DocContentHome;
import fr.paris.lutece.plugins.blog.business.Tag;
import fr.paris.lutece.plugins.blog.business.TagHome;
import fr.paris.lutece.plugins.blog.business.portlet.BlogListPortletHome;
import fr.paris.lutece.plugins.blog.business.portlet.BlogPortlet;
import fr.paris.lutece.plugins.blog.business.portlet.BlogPortletHome;
import fr.paris.lutece.plugins.blog.business.portlet.BlogPublicationHome;
import fr.paris.lutece.plugins.blog.service.BlogService;
import fr.paris.lutece.plugins.blog.service.BlogServiceSession;
import fr.paris.lutece.portal.business.portlet.PortletHome;
import fr.paris.lutece.portal.business.rbac.RBAC;
import fr.paris.lutece.portal.web.portlet.PortletJspBean;
import fr.paris.lutece.util.ReferenceList;
import fr.paris.lutece.util.html.HtmlTemplate;
import fr.paris.lutece.portal.service.util.AppPathService;
import fr.paris.lutece.portal.service.admin.AdminUserService;
import fr.paris.lutece.portal.service.rbac.RBACService;
import fr.paris.lutece.portal.business.user.AdminUser;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -54,6 +61,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* This class provides the user interface to manage BlogsPortlet features
Expand All @@ -68,6 +76,9 @@ public class BlogPortletJspBean extends PortletJspBean
public static final String MARK_LIST_HTMLDOC = "blog_list";
public static final String MARK_LIST_PAGES = "pages_list";
public static final String MARK_BLOG_ID = "blog_id";
public static final String MARK_BLOG = "blog";

public static final String MARK_LIST_IMAGE_TYPE = "image_type";

public static final String PARAMETER_CONTENT_ID = "content_id";
public static final String PARAMETER_HTML_CONTENT = "html_content";
Expand All @@ -77,6 +88,16 @@ public class BlogPortletJspBean extends PortletJspBean
private static final String PARAMETER_PAGE_TEMPLATE_CODE = "page_template_code";

public static final String TEMPLATE_MODIFY_PORTLET = "admin/portlet/modify_portlet.html";
public Blog blog;


protected static final String MESSAGE_CONFIRM_REMOVE_TAG = "blog.message.confirmRemoveTag";
protected static final String MARK_PERMISSION_CREATE_TAG = "permission_manage_create_tag";
protected static final String MARK_PERMISSION_MODIFY_TAG = "permission_manage_modify_tag";
protected static final String MARK_PERMISSION_DELETE_TAG = "permission_manage_delete_tag";

protected static final String MARK_LIST_TAG = "list_tag";
public BlogServiceSession blogServiceSession = BlogServiceSession.getInstance( );

/**
* Returns the BlogPortlet form of creation
Expand All @@ -96,11 +117,33 @@ public String getCreate( HttpServletRequest request )
model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
model.put( MARK_LIST_HTMLDOC, listBlog );
model.put( MARK_LIST_PAGES, BlogListPortletHome.loadPages( BlogPortlet.RESOURCE_ID ) );
blog = ( blog != null && blog.getId( ) == 0 ) ? blog : new Blog( );
blogServiceSession.saveBlogInSession( request.getSession( ), blog );
blog.getTag( ).sort( ( tg1, tg2 ) -> tg1.getPriority( ) - tg2.getPriority( ) );
model.put( MARK_BLOG, blog);
boolean bPermissionCreate = RBACService.isAuthorized( Tag.PROPERTY_RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, Tag.PERMISSION_CREATE, getUser( ) );
model.put( MARK_LIST_IMAGE_TYPE, DocContentHome.getListContentType( ) );
model.put( MARK_PERMISSION_CREATE_TAG, bPermissionCreate );
model.put( MARK_BLOG, blog );
model.put( MARK_LIST_TAG, getTageList( ) );

HtmlTemplate template = getCreateTemplate( strPageId, strPortletTypeId, model );

return template.getHtml( );
}

private ReferenceList getTageList( )
{

ReferenceList BlogList = TagHome.getTagsReferenceList( );

for ( Tag tg : blog.getTag( ) )
{
BlogList.removeIf( item -> item.getCode( ).equals( String.valueOf( tg.getIdTag( ) ) ) );

}
return BlogList;
}

/**
* Returns the BlogPortlet form for update
Expand All @@ -123,6 +166,14 @@ public String getModify( HttpServletRequest request )
model.put( MARK_LIST_PAGES, BlogListPortletHome.loadPages( BlogPortlet.RESOURCE_ID ) );
model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
model.put( MARK_BLOG_ID, blog.getId( ) );
model.put( MARK_LIST_TAG, getTageList( ) );
blog.getTag( ).sort( ( tg1, tg2 ) -> tg1.getPriority( ) - tg2.getPriority( ) );
blog.getDocContent( ).sort( ( dc1, dc2 ) -> dc1.getPriority( ) - dc2.getPriority( ) );
blogServiceSession.saveBlogInSession( request.getSession( ), blog );

boolean bPermissionCreate = RBACService.isAuthorized( Tag.PROPERTY_RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, Tag.PERMISSION_CREATE, getUser( ) );
model.put( MARK_PERMISSION_CREATE_TAG, bPermissionCreate );
model.put( MARK_BLOG, blog );

HtmlTemplate template = getModifyTemplate( portlet, model );

Expand All @@ -143,11 +194,13 @@ public String doCreate( HttpServletRequest request )
AdminUser user = AdminUserService.getAdminUser( request );
String strSelectedBlog = request.getParameter( PARAMETER_HTMLDOC_SELECTED );
String strTemplateCode = request.getParameter( PARAMETER_PAGE_TEMPLATE_CODE );
int nIdBlog = Integer.parseInt( request.getParameter( "id" ) );
BlogServiceSession blogServiceSession = BlogServiceSession.getInstance( );

// recovers portlet specific attributes
String strPageId = request.getParameter( PARAMETER_PAGE_ID );
int nPageId = Integer.parseInt( strPageId );
Blog blog = new Blog( );
Blog blog = blogServiceSession.getBlogFromSession( request.getSession( ), nIdBlog ) !=null ? blogServiceSession.getBlogFromSession( request.getSession( ), nIdBlog ) : new Blog( );
if ( strSelectedBlog == null || StringUtils.isEmpty( strSelectedBlog ) || !StringUtils.isNumeric( strSelectedBlog ) )
{
blog.setContentLabel( request.getParameter( PARAMETER_PORTLET_NAME ) );
Expand All @@ -159,12 +212,14 @@ public String doCreate( HttpServletRequest request )
blog.setEditComment( request.getParameter( PARAMETER_EDIT_COMMENT ) );
blog.setUser( user.getAccessCode( ) );
blog.setUserCreator( user.getAccessCode( ) );
BlogHome.addInitialVersion( blog );
populate( blog, request );

}
else
{
blog = BlogHome.findByPrimaryKey( Integer.parseInt( strSelectedBlog ) );
}
BlogService.getInstance( ).createBlog( blog, blog.getDocContent( ) );
int nContentId = blog.getId( );

// get portlet common attributes
Expand Down