001
014
015 package com.liferay.portlet.enterpriseadmin;
016
017 import com.liferay.portal.model.Organization;
018 import com.liferay.portal.model.Portlet;
019 import com.liferay.portal.security.permission.ActionKeys;
020 import com.liferay.portal.security.permission.PermissionChecker;
021 import com.liferay.portal.service.OrganizationLocalServiceUtil;
022 import com.liferay.portal.service.permission.OrganizationPermissionUtil;
023 import com.liferay.portlet.BaseControlPanelEntry;
024
025 import java.util.List;
026
027
030 public class UsersControlPanelEntry extends BaseControlPanelEntry {
031
032 public boolean isVisible(
033 PermissionChecker permissionChecker, Portlet portlet)
034 throws Exception {
035
036 List<Organization> organizations =
037 OrganizationLocalServiceUtil.getUserOrganizations(
038 permissionChecker.getUserId());
039
040 for (Organization organization : organizations) {
041 if (OrganizationPermissionUtil.contains(
042 permissionChecker, organization.getOrganizationId(),
043 ActionKeys.MANAGE_USERS)) {
044
045 return true;
046 }
047
048 if (OrganizationPermissionUtil.contains(
049 permissionChecker, organization.getOrganizationId(),
050 ActionKeys.MANAGE_SUBORGANIZATIONS)) {
051
052 return true;
053 }
054
055 if (OrganizationPermissionUtil.contains(
056 permissionChecker, organization.getOrganizationId(),
057 ActionKeys.VIEW)) {
058
059 return true;
060 }
061 }
062
063 return false;
064 }
065
066 }