Example usage for com.liferay.portal.kernel.service OrganizationLocalServiceUtil hasUserOrganization

List of usage examples for com.liferay.portal.kernel.service OrganizationLocalServiceUtil hasUserOrganization

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service OrganizationLocalServiceUtil hasUserOrganization.

Prototype

public static boolean hasUserOrganization(long userId, long organizationId, boolean inheritSuborganizations,
        boolean includeSpecifiedOrganization) throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Returns true if the user is a member of the organization, optionally focusing on suborganizations or the specified organization.

Usage

From source file:com.liferay.message.boards.web.internal.util.MBUserRankUtil.java

License:Open Source License

private static boolean _isEntityRank(long companyId, MBStatsUser statsUser, String entityType,
        String entityValue) throws Exception {

    long groupId = statsUser.getGroupId();
    long userId = statsUser.getUserId();

    if (entityType.equals("organization-role") || entityType.equals("site-role")) {

        Role role = RoleLocalServiceUtil.getRole(companyId, entityValue);

        if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(userId, groupId, role.getRoleId(), true)) {

            return true;
        }//from w ww  .  j  a v  a  2s .c o m
    } else if (entityType.equals("organization")) {
        Organization organization = OrganizationLocalServiceUtil.getOrganization(companyId, entityValue);

        if (OrganizationLocalServiceUtil.hasUserOrganization(userId, organization.getOrganizationId(), false,
                false)) {

            return true;
        }
    } else if (entityType.equals("regular-role")) {
        if (RoleLocalServiceUtil.hasUserRole(userId, companyId, entityValue, true)) {

            return true;
        }
    } else if (entityType.equals("user-group")) {
        UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(companyId, entityValue);

        if (UserLocalServiceUtil.hasUserGroupUser(userGroup.getUserGroupId(), userId)) {

            return true;
        }
    }

    return false;
}