I have a web application hosted on the liferay portal. There are certain functions, such as displaying a save button for specific users only based on user permissions defined in liferay.
I have configured permissions in the XML file as shown below using the link from
http://www.liferay.com/community/wiki/-/wiki/Main/Permissioning+in+Plugin+Environment#section-Permissioning+in+Plugin+ Environment-DEFINING + PERMISSION + FOR + A + PORTLET + RESOURCE + IN + PLUGIN + ENVIRONMENT
<?xml version="1.0"?>
<resource-action-mapping>
<portlet-resource>
<portlet-name>TESTPortlet</portlet-name>
<permissions>
<supports>
<action-key>SEARCH_BUTTON</action-key>
<action-key>SAVE_BUTTON</action-key>
<action-key>DELETE_BUTTON</action-key>
</supports>
</permissions>
</portlet-resource>
</resource-action-mapping>
I see the specified permissions on the Permissions tab on the portal in my portlet. I also assigned SAVE_BUTTON permission to one of the user roles (TEST_ADMIN is my role).
jsp java, SAVE_BUTTON.
.
<c:if test="<%= PortletPermissionUtil.contains(permissionChecker,plid.longValue(), "TESTPortlet_WAR_TESTPortlet5121","SAVE_BUTTON") %>">
, , SEARCH_BUTTON . false, , . , , , .
, Liferay SVN repo, .
%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
long groupId = scopeGroupId;
String name = portletDisplay.getRootPortletId();
String primKey = portletDisplay.getResourcePK();
String actionId = "ADD_SOMETHING";
%>
Do you have the <i><liferay-ui:message key='<%= "action." + actionId %>' /></i> permission for this portlet?
<strong>
<c:choose>
<c:when test="<%= permissionChecker.hasPermission(groupId, name, primKey, actionId) %>">
Yes
</c:when>
<c:otherwise>
No
</c:otherwise>
</c:choose>
</strong>
- , , , .
.