Example usage for com.liferay.portal.kernel.service UserLocalServiceUtil hasUserGroupUser

List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil hasUserGroupUser

Introduction

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

Prototype

public static boolean hasUserGroupUser(long userGroupId, long userId) 

Source Link

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;
        }// ww w  . java  2 s  . co 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;
}