001
014
015 package com.liferay.portlet;
016
017 import com.liferay.portal.model.Group;
018 import com.liferay.portal.model.LayoutConstants;
019 import com.liferay.portal.model.Portlet;
020 import com.liferay.portal.security.permission.ActionKeys;
021 import com.liferay.portal.security.permission.PermissionChecker;
022 import com.liferay.portal.service.permission.PortletPermissionUtil;
023 import com.liferay.portal.theme.ThemeDisplay;
024 import com.liferay.portal.util.PortletCategoryKeys;
025
026
029 public abstract class BaseControlPanelEntry implements ControlPanelEntry {
030
031 public boolean isVisible(
032 Portlet portlet, String category, ThemeDisplay themeDisplay)
033 throws Exception {
034
035 PermissionChecker permissionChecker =
036 themeDisplay.getPermissionChecker();
037
038 if (permissionChecker.isCompanyAdmin()) {
039 return true;
040 }
041
042 Group group = themeDisplay.getScopeGroup();
043
044 long plid = LayoutConstants.DEFAULT_PLID;
045
046 if (category.equals(PortletCategoryKeys.CONTENT)) {
047 plid = group.getDefaultPublicPlid();
048
049 if (plid == LayoutConstants.DEFAULT_PLID) {
050 plid = group.getDefaultPrivatePlid();
051 }
052 }
053
054 if (category.equals(PortletCategoryKeys.CONTENT) &&
055 permissionChecker.isCommunityAdmin(group.getGroupId())) {
056
057 return true;
058 }
059
060 if (PortletPermissionUtil.contains(
061 permissionChecker, plid, portlet.getPortletId(),
062 ActionKeys.ACCESS_IN_CONTROL_PANEL, true)) {
063
064 return true;
065 }
066
067 return isVisible(themeDisplay.getPermissionChecker(), portlet);
068 }
069
070 }