public boolean isShowIconsActions() throws PortalException {
    if (isSpreadsheet()) {
      return false;
    }

    if (_hasShowIconsActionPermission != null) {
      return _hasShowIconsActionPermission;
    }

    _hasShowIconsActionPermission = Boolean.FALSE;

    ThemeDisplay themeDisplay = getThemeDisplay();

    if (!themeDisplay.isSignedIn()) {
      return _hasShowIconsActionPermission;
    }

    Layout layout = themeDisplay.getLayout();

    if (layout.isLayoutPrototypeLinkActive()) {
      return _hasShowIconsActionPermission;
    }

    if (isShowConfigurationIcon()
        || isShowAddDDMDisplayTemplateIcon()
        || isShowAddDDMFormTemplateIcon()
        || isShowEditDisplayDDMTemplateIcon()
        || isShowEditFormDDMTemplateIcon()) {

      _hasShowIconsActionPermission = Boolean.TRUE;
    }

    return _hasShowIconsActionPermission;
  }
예제 #2
0
  @Override
  public PortletURL getViewContentURL(HttpServletRequest request, String className, long classPK)
      throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String portletId =
        PortletProviderUtil.getPortletId(TrashEntry.class.getName(), PortletProvider.Action.VIEW);

    if (!themeDisplay.isSignedIn()
        || !isTrashEnabled(themeDisplay.getScopeGroupId())
        || !PortletPermissionUtil.hasControlPanelAccessPermission(
            themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) {

      return null;
    }

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    if (trashHandler.isInTrashContainer(classPK)) {
      TrashEntry trashEntry = trashHandler.getTrashEntry(classPK);

      className = trashEntry.getClassName();
      classPK = trashEntry.getClassPK();

      trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);
    }

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

    if (trashRenderer == null) {
      return null;
    }

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/view_content.jsp");
    portletURL.setParameter("redirect", themeDisplay.getURLCurrent());

    TrashEntry trashEntry = TrashEntryLocalServiceUtil.getEntry(className, classPK);

    if (trashEntry.getRootEntry() != null) {
      portletURL.setParameter("className", className);
      portletURL.setParameter("classPK", String.valueOf(classPK));
    } else {
      portletURL.setParameter("trashEntryId", String.valueOf(trashEntry.getEntryId()));
    }

    portletURL.setParameter("showAssetMetadata", Boolean.TRUE.toString());

    return portletURL;
  }
예제 #3
0
  @Override
  public PortletURL getViewURL(HttpServletRequest request) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String portletId =
        PortletProviderUtil.getPortletId(TrashEntry.class.getName(), PortletProvider.Action.VIEW);

    if (!themeDisplay.isSignedIn()
        || !isTrashEnabled(themeDisplay.getScopeGroupId())
        || !PortletPermissionUtil.hasControlPanelAccessPermission(
            themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) {

      return null;
    }

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("redirect", themeDisplay.getURLCurrent());

    return portletURL;
  }
  @Override
  public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {

    try {

      // Do not randomize look and feel unless the user is logged in

      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      if (!themeDisplay.isSignedIn()) {
        return;
      }

      // Do not randomize look and feel unless the user is accessing the
      // portal

      String requestURI = GetterUtil.getString(request.getRequestURI());

      if (!requestURI.endsWith("/portal/layout")) {
        return;
      }

      // Do not randomize look and feel unless the user is accessing a
      // personal layout

      Layout layout = themeDisplay.getLayout();

      if (layout == null) {
        return;
      }

      boolean wapTheme = BrowserSnifferUtil.isWap(request);

      List<Theme> themes =
          ThemeLocalServiceUtil.getPageThemes(
              themeDisplay.getCompanyId(),
              themeDisplay.getScopeGroupId(),
              themeDisplay.getUserId(),
              wapTheme);

      if (!themes.isEmpty()) {
        Theme theme = themes.get(RandomUtil.nextInt(themes.size()));

        List<ColorScheme> colorSchemes = theme.getColorSchemes();

        ColorScheme colorScheme = colorSchemes.get(RandomUtil.nextInt(colorSchemes.size()));

        LayoutServiceUtil.updateLookAndFeel(
            layout.getGroupId(),
            layout.isPrivateLayout(),
            layout.getPlid(),
            theme.getThemeId(),
            colorScheme.getColorSchemeId(),
            layout.getCss(),
            wapTheme);

        themeDisplay.setLookAndFeel(theme, colorScheme);

        request.setAttribute(WebKeys.THEME, theme);
        request.setAttribute(WebKeys.COLOR_SCHEME, colorScheme);
      }
    } catch (Exception e) {
      _log.error(e, e);

      throw new ActionException(e);
    }
  }
  @Override
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession();

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String languageId = ParamUtil.getString(request, "languageId");

    Locale locale = LocaleUtil.fromLanguageId(languageId);

    if (LanguageUtil.isAvailableLocale(themeDisplay.getSiteGroupId(), locale)) {

      boolean persistState = ParamUtil.getBoolean(request, "persistState", true);

      if (themeDisplay.isSignedIn() && persistState) {
        User user = themeDisplay.getUser();

        Contact contact = user.getContact();

        AdminUtil.updateUser(
            request,
            user.getUserId(),
            user.getScreenName(),
            user.getEmailAddress(),
            user.getFacebookId(),
            user.getOpenId(),
            languageId,
            user.getTimeZoneId(),
            user.getGreeting(),
            user.getComments(),
            contact.getSmsSn(),
            contact.getFacebookSn(),
            contact.getJabberSn(),
            contact.getSkypeSn(),
            contact.getTwitterSn());
      }

      session.setAttribute(Globals.LOCALE_KEY, locale);

      LanguageUtil.updateCookie(request, response, locale);
    }

    // Send redirect

    String redirect = ParamUtil.getString(request, "redirect");

    String layoutURL = StringPool.BLANK;
    String queryString = StringPool.BLANK;

    int pos = redirect.indexOf(Portal.FRIENDLY_URL_SEPARATOR);

    if (pos == -1) {
      pos = redirect.indexOf(StringPool.QUESTION);
    }

    if (pos != -1) {
      layoutURL = redirect.substring(0, pos);
      queryString = redirect.substring(pos);
    } else {
      layoutURL = redirect;
    }

    Layout layout = themeDisplay.getLayout();

    if (isGroupFriendlyURL(layout.getGroup(), layout, layoutURL, locale)) {
      if (PropsValues.LOCALE_PREPEND_FRIENDLY_URL_STYLE == 0) {
        redirect = layoutURL;
      } else {
        redirect = PortalUtil.getGroupFriendlyURL(layout.getLayoutSet(), themeDisplay, locale);
      }
    } else {
      if (PropsValues.LOCALE_PREPEND_FRIENDLY_URL_STYLE == 0) {
        if (themeDisplay.isI18n()) {
          redirect = layout.getFriendlyURL(locale);
        } else {
          redirect = PortalUtil.getLayoutURL(layout, themeDisplay, locale);
        }
      } else {
        redirect = PortalUtil.getLayoutFriendlyURL(layout, themeDisplay, locale);
      }
    }

    if (layout.isTypeControlPanel()) {
      redirect = redirect + queryString;
    }

    response.sendRedirect(redirect);

    return null;
  }