Example usage for com.liferay.portal.kernel.util PropsKeys SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED

List of usage examples for com.liferay.portal.kernel.util PropsKeys SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED.

Prototype

String SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED

To view the source code for com.liferay.portal.kernel.util PropsKeys SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED.

Click Source Link

Usage

From source file:com.liferay.content.targeting.util.ContentTargetingUtil.java

License:Open Source License

public static long[] getSharedContentSiteGroupIds(long companyId, long groupId, long userId)
        throws PortalException, SystemException {

    Set<Group> groups = new LinkedHashSet<Group>();

    Group siteGroup = doGetCurrentSiteGroup(groupId);

    if (siteGroup != null) {

        // Current site

        groups.add(siteGroup);/*from   w  w  w  . ja  v a2 s.  co m*/

        // Layout scopes

        groups.addAll(GroupLocalServiceUtil.getGroups(siteGroup.getCompanyId(), Layout.class.getName(),
                siteGroup.getGroupId()));
    }

    // Administered sites

    if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) {

        LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>();

        groupParams.put("site", Boolean.TRUE);
        groupParams.put("usersGroups", userId);

        groups.addAll(GroupLocalServiceUtil.search(companyId, null, null, groupParams, QueryUtil.ALL_POS,
                QueryUtil.ALL_POS, null));
    }

    // Descendant sites

    groups.addAll(getDescendants(siteGroup, true));

    // Ancestor sites and global site

    int sitesContentSharingWithChildrenEnabled = PrefsPropsUtil.getInteger(companyId,
            PropsKeys.SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED);

    if (sitesContentSharingWithChildrenEnabled != Sites.CONTENT_SHARING_WITH_CHILDREN_DISABLED) {

        groups.addAll(doGetAncestorSiteGroups(groupId, true));
    }

    long[] groupIds = new long[groups.size()];

    int i = 0;

    for (Group group : groups) {
        groupIds[i++] = group.getGroupId();
    }

    return groupIds;
}

From source file:com.liferay.site.admin.web.internal.servlet.taglib.ui.SiteContentSharingFormNavigatorEntry.java

License:Open Source License

@Override
public boolean isVisible(User user, Group group) {
    if (group == null) {
        return false;
    }//from w  w w . j  a  v a 2 s.c  o m

    int contentSharingWithChildrenEnabled = PrefsPropsUtil.getInteger(group.getCompanyId(),
            PropsKeys.SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED);

    if (contentSharingWithChildrenEnabled == 0) {
        return false;
    }

    return true;
}