@Override public Group getGroup() { return _organization.getGroup(); }
@Override public boolean isRoleProtected( PermissionChecker permissionChecker, long userId, long organizationId, long roleId) throws PortalException { if (permissionChecker.isOrganizationOwner(organizationId)) { return false; } Role role = RoleLocalServiceUtil.getRole(roleId); String roleName = role.getName(); if (!roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) && !roleName.equals(RoleConstants.ORGANIZATION_OWNER)) { return false; } Organization organization = OrganizationLocalServiceUtil.getOrganization(organizationId); Group group = organization.getGroup(); if (UserGroupRoleLocalServiceUtil.hasUserGroupRole( userId, group.getGroupId(), role.getRoleId())) { return true; } return false; }
private static LayoutSet _getParentLayoutSet(LayoutSet layoutSet) throws Exception { Group group = layoutSet.getGroup(); if (group.isSite()) { Group parentGroup = group.getParentGroup(); if (parentGroup != null) { return LayoutSetLocalServiceUtil.getLayoutSet( parentGroup.getGroupId(), layoutSet.isPrivateLayout()); } } else if (group.isUser()) { User user = UserLocalServiceUtil.getUser(group.getClassPK()); List<Organization> organizations = OrganizationLocalServiceUtil.getUserOrganizations( user.getUserId()); if (!organizations.isEmpty()) { Organization organization = organizations.get(0); Group parentGroup = organization.getGroup(); return LayoutSetLocalServiceUtil.getLayoutSet( parentGroup.getGroupId(), layoutSet.isPrivateLayout()); } } return null; }
@Override public boolean isMembershipProtected( PermissionChecker permissionChecker, long userId, long organizationId) throws PortalException { if (permissionChecker.isOrganizationOwner(organizationId)) { return false; } Organization organization = OrganizationLocalServiceUtil.getOrganization(organizationId); Group group = organization.getGroup(); Role organizationAdministratorRole = RoleLocalServiceUtil.getRole( permissionChecker.getCompanyId(), RoleConstants.ORGANIZATION_ADMINISTRATOR); if (UserGroupRoleLocalServiceUtil.hasUserGroupRole( userId, group.getGroupId(), organizationAdministratorRole.getRoleId())) { return true; } Role organizationOwnerRole = RoleLocalServiceUtil.getRole( permissionChecker.getCompanyId(), RoleConstants.ORGANIZATION_OWNER); if (UserGroupRoleLocalServiceUtil.hasUserGroupRole( userId, group.getGroupId(), organizationOwnerRole.getRoleId())) { return true; } return false; }