001
014
015 package com.liferay.portlet.sitesadmin;
016
017 import com.liferay.portal.model.Portlet;
018 import com.liferay.portal.security.permission.PermissionChecker;
019 import com.liferay.portal.service.GroupLocalServiceUtil;
020 import com.liferay.portal.theme.ThemeDisplay;
021 import com.liferay.portal.util.PortletCategoryKeys;
022 import com.liferay.portal.util.PropsValues;
023 import com.liferay.portlet.BaseControlPanelEntry;
024
025 import java.util.LinkedHashMap;
026
027
032 public class SitesControlPanelEntry extends BaseControlPanelEntry {
033
034 @Override
035 public boolean isVisible(
036 PermissionChecker permissionChecker, Portlet portlet)
037 throws Exception {
038
039 if (PropsValues.SITES_CONTROL_PANEL_MEMBERS_VISIBLE) {
040 LinkedHashMap<String, Object> groupParams =
041 new LinkedHashMap<String, Object>();
042
043 groupParams.put("site", Boolean.TRUE);
044 groupParams.put("usersGroups", permissionChecker.getUserId());
045
046 int count = GroupLocalServiceUtil.searchCount(
047 permissionChecker.getCompanyId(), null, null, groupParams);
048
049 if (count > 0) {
050 return true;
051 }
052 }
053
054 return false;
055 }
056
057 @Override
058 public boolean isVisible(
059 Portlet portlet, String category, ThemeDisplay themeDisplay)
060 throws Exception {
061
062 String controlPanelCategory = themeDisplay.getControlPanelCategory();
063
064 if (controlPanelCategory.equals(PortletCategoryKeys.CONTENT)) {
065 return false;
066 }
067
068 return super.isVisible(portlet, category, themeDisplay);
069 }
070
071 }