Example usage for com.liferay.portal.kernel.security.permission ActionKeys MANAGE_USERS

List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys MANAGE_USERS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.permission ActionKeys MANAGE_USERS.

Prototype

String MANAGE_USERS

To view the source code for com.liferay.portal.kernel.security.permission ActionKeys MANAGE_USERS.

Click Source Link

Usage

From source file:com.liferay.users.admin.web.internal.portlet.configuration.icon.AssignUsersPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    try {//from  w  w  w.j  a  v  a2s  .  c om
        PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

        Organization organization = ActionUtil.getOrganization(portletRequest);

        if (OrganizationPermissionUtil.contains(permissionChecker, organization, ActionKeys.MANAGE_USERS)) {

            return true;
        }
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.users.admin.web.internal.portlet.UsersControlPanelEntry.java

License:Open Source License

@Override
protected boolean hasPermissionImplicitlyGranted(PermissionChecker permissionChecker, Group group,
        Portlet portlet) throws Exception {

    List<UserGroupRole> userGroupRoles = _userGroupRoleLocalService
            .getUserGroupRoles(permissionChecker.getUserId());

    for (UserGroupRole userGroupRole : userGroupRoles) {
        Role role = userGroupRole.getRole();

        String roleName = role.getName();

        if (roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR)
                || roleName.equals(RoleConstants.ORGANIZATION_OWNER)) {

            return true;
        }/*from w ww .j  a  v a 2  s .c o  m*/
    }

    List<Organization> organizations = _organizationLocalService
            .getUserOrganizations(permissionChecker.getUserId());

    for (Organization organization : organizations) {
        if (OrganizationPermissionUtil.contains(permissionChecker, organization, ActionKeys.MANAGE_USERS)) {

            return true;
        }

        if (OrganizationPermissionUtil.contains(permissionChecker, organization,
                ActionKeys.MANAGE_SUBORGANIZATIONS)) {

            return true;
        }

        /*if (OrganizationPermissionUtil.contains(
              permissionChecker, organization.getOrganizationId(),
              ActionKeys.VIEW)) {
                
           return true;
        }*/
    }

    return super.hasPermissionImplicitlyGranted(permissionChecker, group, portlet);
}