protected String[] getStaticPortletIds(String position) {
    Layout layout = getLayout();

    String selector1 = StringPool.BLANK;

    Group group = null;

    try {
      group = layout.getGroup();
    } catch (PortalException pe) {
      _log.error("Unable to get group " + layout.getGroupId());

      return new String[0];
    }

    if (group.isUser()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_USER_SELECTOR;
    } else if (group.isOrganization()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_ORGANIZATION_SELECTOR;
    } else if (group.isRegularSite()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_REGULAR_SITE_SELECTOR;
    }

    String selector2 = layout.getFriendlyURL();

    String[] portletIds = PropsUtil.getArray(position, new Filter(selector1, selector2));

    for (int i = 0; i < portletIds.length; i++) {
      portletIds[i] = JS.getSafeName(portletIds[i]);
    }

    return portletIds;
  }
Exemplo n.º 2
0
  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 isVisible(User user, Layout layout) {
    try {
      Group group = layout.getGroup();

      if (!group.isUser() && layout.isTypePortlet()) {
        return true;
      }
    } catch (PortalException pe) {
      _log.error("Unable to display form for customization settings", pe);
    }

    return false;
  }