@Override public String getScopeId(Group group, long scopeGroupId) throws PortalException, SystemException { String key = null; if (group.isLayout()) { Layout layout = LayoutLocalServiceUtil.getLayout(group.getClassPK()); key = SCOPE_ID_LAYOUT_UUID_PREFIX + layout.getUuid(); } else if (group.isLayoutPrototype() || (group.getGroupId() == scopeGroupId)) { key = SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT; } else { Group scopeGroup = GroupLocalServiceUtil.getGroup(scopeGroupId); if (scopeGroup.hasAncestor(group.getGroupId())) { key = SCOPE_ID_PARENT_GROUP_PREFIX + group.getGroupId(); } else if (group.hasAncestor(scopeGroup.getGroupId())) { key = SCOPE_ID_CHILD_GROUP_PREFIX + group.getGroupId(); } else { key = SCOPE_ID_GROUP_PREFIX + group.getGroupId(); } } return key; }
@Override public boolean isScopeIdSelectable( PermissionChecker permissionChecker, String scopeId, long companyGroupId, Layout layout) throws PortalException, SystemException { long groupId = getGroupIdFromScopeId(scopeId, layout.getGroupId(), layout.isPrivateLayout()); if (scopeId.startsWith(SCOPE_ID_CHILD_GROUP_PREFIX)) { Group group = GroupLocalServiceUtil.getGroup(groupId); if (!group.hasAncestor(layout.getGroupId())) { return false; } } else if (scopeId.startsWith(SCOPE_ID_PARENT_GROUP_PREFIX)) { Group siteGroup = layout.getGroup(); if (!siteGroup.hasAncestor(groupId)) { return false; } if (SitesUtil.isContentSharingWithChildrenEnabled(siteGroup)) { return true; } if (!PrefsPropsUtil.getBoolean( layout.getCompanyId(), PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) { return false; } return GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.UPDATE); } else if (groupId != companyGroupId) { return GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.UPDATE); } return true; }
@Override public String getScopeLabel(ThemeDisplay themeDisplay) { String label = "site"; if (getGroupId() == themeDisplay.getScopeGroupId()) { label = "current-site"; } else if (getGroupId() == themeDisplay.getCompanyGroupId()) { label = "global"; } else if (isLayout()) { label = "page"; } else { Group scopeGroup = themeDisplay.getScopeGroup(); if (scopeGroup.hasAncestor(getGroupId())) { label = "parent-site"; } else if (hasAncestor(scopeGroup.getGroupId())) { label = "child-site"; } } return label; }