This is how we achieved it:
- Create a custom portlet with the permissions file for this portlet like
/resource-actions/custompermission.xml
to specify the different custom permissions we want. The full steps are identical to this wiki. - Make this portlet a hidden portlet so that it won't appear in the
Add
menu in dockbar, neither in Control-panel nor in theDefine Permissions
drop-down. Now create a JSP hook (you can either create a separate plugin or include the hook in the custom-portlet defined in point no. 1) and modify the
/docroot/html/portlet/roles_admin/edit_role_permissions_navigation.jspf
to include our custom category:<aui:form action="<%= currentURL %>" name="resourceSelection"> <aui:fieldset> <aui:select changesContext="<%= true %>" name="add-permissions" onchange='<%= renderResponse.getNamespace() + "addPermissions(this);" %>'> <aui:option label="" /> <%-- Our customization starts here --%> <%-- We have added our very own option group but this is not required just the <aui:option> will do --%> <optgroup label="<liferay-ui:message key="custom" />"> <% if (_isCustomPermissionsPortlet(CUSTOM_PERMISSIONS_PORTLET)) { editPermissionsURL.setParameter("portletResource", CUSTOM_PERMISSIONS_PORTLET); editPermissionsURL.setParameter("showModelResources", "0"); %> <%-- and here we add our own Permission category drop-down option --%> <aui:option label="custom-permissions" selected="<%= _isCurrent(editPermissionsURL.toString(), portletResource, showModelResources) %>" value="<%= editPermissionsURL.toString() %>" /> <% } %> </optgroup> <%-- Our customization ends here --%> <c:choose> <c:when test="<%= role.getType() == RoleConstants.TYPE_SITE %>"> <optgroup label="<liferay-ui:message key="administration" />"> <% // Other liferay stuff continues ...
and at the end of the JSP we have:
// ... other liferay stuff private boolean _isOrganizationPortlet(String portletId) { return ArrayUtil.contains(_ORGANIZATION_PORTLETS, portletId); } private boolean _isPortalPortlet(String portletId) { return ArrayUtil.contains(_PORTAL_PORTLETS, portletId); } // Our customization starts here // portlet's ID public static final String CUSTOM_PERMISSIONS_PORTLET = "CustomPermissions_WAR_CustomPermissionsportlet"; private static final String[] _CUSTOM_PERMISSIONS_PORTLET = { CUSTOM_PERMISSIONS_PORTLET, }; private boolean _isCustomPermissionsPortlet(String portletId) { return ArrayUtil.contains(_CUSTOM_PERMISSIONS_PORTLET, portletId); } // Our customization ends here
This is how it looks in the Control Panel:
We can move the permissions in the
Portal
section as well by moving our customized code to that place in the JSP.The advantage of having it above is that it will be displayed when we want to set Define Permissions for Site Role.
Hope this helps somebody.