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 @Override
032 public boolean isVisible(
033 Portlet portlet, String category, ThemeDisplay themeDisplay)
034 throws Exception {
035
036 PermissionChecker permissionChecker =
037 themeDisplay.getPermissionChecker();
038
039 if (permissionChecker.isCompanyAdmin()) {
040 return true;
041 }
042
043 Group group = themeDisplay.getScopeGroup();
044
045 long plid = LayoutConstants.DEFAULT_PLID;
046
047 if (category.equals(PortletCategoryKeys.CONTENT)) {
048 plid = group.getDefaultPublicPlid();
049
050 if (plid == LayoutConstants.DEFAULT_PLID) {
051 plid = group.getDefaultPrivatePlid();
052 }
053 }
054
055 if (category.equals(PortletCategoryKeys.CONTENT) &&
056 permissionChecker.isGroupAdmin(group.getGroupId()) &&
057 !group.isUser()) {
058
059 return true;
060 }
061
062 long groupId = group.getGroupId();
063
064 if (category.equals(PortletCategoryKeys.PORTAL) ||
065 category.equals(PortletCategoryKeys.SERVER)) {
066
067 groupId = 0;
068 }
069
070 if (PortletPermissionUtil.contains(
071 permissionChecker, groupId, plid, portlet.getPortletId(),
072 ActionKeys.ACCESS_IN_CONTROL_PANEL, true)) {
073
074 return true;
075 }
076
077 return isVisible(themeDisplay.getPermissionChecker(), portlet);
078 }
079
080 }