The asset framework supports a system for flagging inappropriate content in apps. The steps here show you how to enable it in your app.
Figure 1: Users can flag objectionable content.
Follow these steps to enable content flagging in your app:
-
Make sure your entity is asset enabled.
-
Choose a read-only view of the entity you want to enable flags on. You can display flags in one of your app’s views, or if you’ve implemented asset rendering you can display it in the full content view in the Asset Publisher app.
-
In your JSP, include the
liferay-flags
taglib declaration:<%@ taglib prefix="liferay-flags" uri="http://liferay.com/tld/flags" %>
-
Use
ParamUtil
to get the entity’s ID from the render request. Then use your-LocalServiceUtil
class to create an entity object:<% long entryId = ParamUtil.getLong(renderRequest, "entryId"); entry = EntryLocalServiceUtil.getEntry(entryId); %>
-
Use the
liferay-flags:flags
tag to add the flags component:<liferay-flags:flags className="<%= Entry.class.getName() %>" classPK="<%= entry.getEntryId() %>" contentTitle="<%= title %>" message="flag-this-content" reportedUserId="<%= reportedUserId %>" />
The
reportedUserId
attribute specifies the ID of the user who flagged the asset.