Example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId.

Prototype

public long getScopeGroupId() 

Source Link

Document

Returns the ID of the scoped or sub-scoped active group (e.g.

Usage

From source file:com.liferay.message.boards.web.internal.portlet.action.MoveThreadMVCActionCommand.java

License:Open Source License

protected void moveThread(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");
    long threadId = ParamUtil.getLong(actionRequest, "threadId");

    MBThread thread = _mbThreadLocalService.getThread(threadId);

    _mbThreadService.moveThread(categoryId, threadId);

    boolean addExplanationPost = ParamUtil.getBoolean(actionRequest, "addExplanationPost");

    if (addExplanationPost) {
        String subject = ParamUtil.getString(actionRequest, "subject");
        String body = ParamUtil.getString(actionRequest, "body");

        MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings
                .getInstance(themeDisplay.getScopeGroupId());

        ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(),
                actionRequest);//www.jav a  2s  .  c  om

        _mbMessageService.addMessage(thread.getRootMessageId(), subject, body,
                mbGroupServiceSettings.getMessageFormat(),
                Collections.<ObjectValuePair<String, InputStream>>emptyList(), false,
                MBThreadConstants.PRIORITY_NOT_GIVEN, false, serviceContext);
    }

    PortletURL portletURL = ((ActionResponseImpl) actionResponse).createRenderURL();

    portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_message");
    portletURL.setParameter("messageId", String.valueOf(thread.getRootMessageId()));

    actionResponse.sendRedirect(portletURL.toString());
}

From source file:com.liferay.message.boards.web.internal.portlet.action.SplitThreadMVCActionCommand.java

License:Open Source License

protected void splitThread(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long messageId = ParamUtil.getLong(actionRequest, "messageId");

    String splitThreadSubject = ParamUtil.getString(actionRequest, "splitThreadSubject");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(MBThread.class.getName(), actionRequest);

    MBMessage message = _mbMessageLocalService.getMessage(messageId);

    long oldParentMessageId = message.getParentMessageId();

    MBThread newThread = _mbThreadService.splitThread(messageId, splitThreadSubject, serviceContext);

    boolean addExplanationPost = ParamUtil.getBoolean(actionRequest, "addExplanationPost");

    if (addExplanationPost) {
        String subject = ParamUtil.getString(actionRequest, "subject");
        String body = ParamUtil.getString(actionRequest, "body");

        MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings
                .getInstance(themeDisplay.getScopeGroupId());

        String layoutFullURL = PortalUtil.getLayoutFullURL(themeDisplay);

        String newThreadURL = layoutFullURL + "/-/message_boards/view_message/" + message.getMessageId();

        body = StringUtil.replace(body, MBThreadConstants.NEW_THREAD_URL, newThreadURL);

        serviceContext.setAddGroupPermissions(true);
        serviceContext.setAddGuestPermissions(true);

        _mbMessageService.addMessage(oldParentMessageId, subject, body,
                mbGroupServiceSettings.getMessageFormat(),
                Collections.<ObjectValuePair<String, InputStream>>emptyList(), false,
                MBThreadConstants.PRIORITY_NOT_GIVEN, message.getAllowPingbacks(), serviceContext);
    }/*from w  ww .j  av a 2  s  .co m*/

    PortletURL portletURL = ((ActionResponseImpl) actionResponse).createRenderURL();

    portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_message");
    portletURL.setParameter("messageId", String.valueOf(newThread.getRootMessageId()));

    actionResponse.sendRedirect(portletURL.toString());
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.CategorySubscriptionPortletConfigurationIcon.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  va2 s  .  c  o  m*/
        MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings
                .getInstance(themeDisplay.getScopeGroupId());

        if (!mbGroupServiceSettings.isEmailMessageAddedEnabled()
                && !mbGroupServiceSettings.isEmailMessageUpdatedEnabled()) {

            return false;
        }

        MBCategory category = ActionUtil.getCategory(portletRequest);

        return MBCategoryPermission.contains(themeDisplay.getPermissionChecker(), category,
                ActionKeys.SUBSCRIBE);
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.DeleteCategoryPortletConfigurationIcon.java

License:Open Source License

@Override
public String getMessage(PortletRequest portletRequest) {
    String key = "delete";

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

    if (isTrashEnabled(themeDisplay.getScopeGroupId())) {
        key = "move-to-the-recycle-bin";
    }/*from w w w  . java 2  s. co m*/

    return LanguageUtil.get(getResourceBundle(getLocale(portletRequest)), key);
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.DeleteCategoryPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    try {//from  w w w .j ava 2  s .  c o  m
        PortletURL deleteURL = PortalUtil.getControlPanelPortletURL(portletRequest,
                MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.ACTION_PHASE);

        deleteURL.setParameter(ActionRequest.ACTION_NAME, "/message_boards/edit_category");

        String cmd = Constants.DELETE;

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

        if (isTrashEnabled(themeDisplay.getScopeGroupId())) {
            cmd = Constants.MOVE_TO_TRASH;
        }

        deleteURL.setParameter(Constants.CMD, cmd);

        PortletURL parentCategoryURL = PortalUtil.getControlPanelPortletURL(portletRequest,
                MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.RENDER_PHASE);

        MBCategory category = ActionUtil.getCategory(portletRequest);

        long parentCategoryId = getCategoryId(category.getParentCategory());

        if (parentCategoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

            parentCategoryURL.setParameter("mvcRenderCommandName", "/message_boards/view");
        } else {
            parentCategoryURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
            parentCategoryURL.setParameter("mbCategoryId", String.valueOf(parentCategoryId));
        }

        deleteURL.setParameter("redirect", parentCategoryURL.toString());

        deleteURL.setParameter("mbCategoryId", String.valueOf(category.getCategoryId()));

        return deleteURL.toString();
    } catch (Exception e) {
    }

    return StringPool.BLANK;
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.DeleteThreadPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    PortletURL deleteURL = PortalUtil.getControlPanelPortletURL(portletRequest,
            MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.ACTION_PHASE);

    deleteURL.setParameter(ActionRequest.ACTION_NAME, "/message_boards/delete_thread");

    String cmd = Constants.DELETE;

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

    if (isTrashEnabled(themeDisplay.getScopeGroupId())) {
        cmd = Constants.MOVE_TO_TRASH;// w ww .  jav  a 2  s  . co  m
    }

    deleteURL.setParameter(Constants.CMD, cmd);

    try {
        MBCategory category = ActionUtil.getCategory(portletRequest);

        PortletURL parentCategoryURL = PortletURLFactoryUtil.create(portletRequest,
                MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.RENDER_PHASE);

        long categoryId = getCategoryId(category);

        if (categoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {
            parentCategoryURL.setParameter("mvcRenderCommandName", "/message_boards/view");
        } else {
            parentCategoryURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
            parentCategoryURL.setParameter("mbCategoryId", String.valueOf(categoryId));
        }

        deleteURL.setParameter("redirect", parentCategoryURL.toString());

        MBMessage message = ActionUtil.getMessage(portletRequest);

        deleteURL.setParameter("threadId", String.valueOf(message.getThreadId()));
    } catch (Exception e) {
        return null;
    }

    return deleteURL.toString();
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.MoveThreadPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {//  w w  w.  j av  a  2  s .  c  o  m
        MBCategory category = ActionUtil.getCategory(portletRequest);

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

        if (MBCategoryPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(),
                getCategoryId(category), ActionKeys.MOVE_THREAD)) {

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

    return false;
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    String url = StringPool.BLANK;

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

    try {/*from w  ww .j av a2s  .  c  o  m*/
        String modelResource = "com.liferay.message.boards";
        String modelResourceDescription = themeDisplay.getScopeGroupName();
        String resourcePrimKey = String.valueOf(themeDisplay.getScopeGroupId());

        url = PermissionsURLTag.doTag(StringPool.BLANK, modelResource, modelResourceDescription, null,
                resourcePrimKey, LiferayWindowState.POP_UP.toString(), null, themeDisplay.getRequest());
    } catch (Exception e) {
    }

    return url;
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

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

    User user = themeDisplay.getUser();//from w  ww. j  av a  2  s  .c o  m

    if (user.isDefaultUser()) {
        return false;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!MBPermission.contains(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.PERMISSIONS)) {

        return false;
    }

    return true;
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.ThreadLockPortletConfigurationIcon.java

License:Open Source License

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

    try {/*from  w  ww.j a v  a  2s.  c  o  m*/
        MBMessage message = ActionUtil.getMessage(portletRequest);

        return MBCategoryPermission.contains(themeDisplay.getPermissionChecker(),
                themeDisplay.getScopeGroupId(), message.getCategoryId(), ActionKeys.LOCK_THREAD);
    } catch (Exception e) {
    }

    return false;
}