001
014
015 package com.liferay.portlet.mypages.action;
016
017 import com.liferay.portal.model.Group;
018 import com.liferay.portal.model.RoleConstants;
019 import com.liferay.portal.model.User;
020 import com.liferay.portal.service.RoleLocalServiceUtil;
021 import com.liferay.portal.struts.PortletAction;
022 import com.liferay.portal.util.PortalUtil;
023 import com.liferay.portal.util.PropsValues;
024 import com.liferay.portlet.RenderRequestImpl;
025 import com.liferay.portlet.communities.action.ActionUtil;
026 import com.liferay.util.servlet.DynamicServletRequest;
027
028 import javax.portlet.PortletConfig;
029 import javax.portlet.RenderRequest;
030 import javax.portlet.RenderResponse;
031 import javax.portlet.WindowState;
032
033 import org.apache.struts.action.ActionForm;
034 import org.apache.struts.action.ActionForward;
035 import org.apache.struts.action.ActionMapping;
036
037
041 public class ViewAction extends PortletAction {
042
043 public ActionForward render(
044 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
045 RenderRequest renderRequest, RenderResponse renderResponse)
046 throws Exception {
047
048 if (renderRequest.getRemoteUser() == null) {
049 return mapping.findForward("portlet.my_pages.view");
050 }
051
052 if (!renderRequest.getWindowState().equals(WindowState.MAXIMIZED)) {
053 return mapping.findForward("portlet.my_pages.view");
054 }
055
056 User user = PortalUtil.getUser(renderRequest);
057
058 RenderRequestImpl renderRequestImpl = (RenderRequestImpl)renderRequest;
059
060 DynamicServletRequest dynamicRequest =
061 (DynamicServletRequest)renderRequestImpl.getHttpServletRequest();
062
063 dynamicRequest.setParameter(
064 "p_u_i_d", String.valueOf(user.getUserId()));
065
066 String tabs1 = "public-pages";
067
068 boolean hasPowerUserRole = RoleLocalServiceUtil.hasUserRole(
069 user.getUserId(), user.getCompanyId(), RoleConstants.POWER_USER,
070 true);
071
072 if (!PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_MODIFIABLE ||
073 (PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_POWER_USER_REQUIRED &&
074 !hasPowerUserRole)) {
075
076 tabs1 = "private-pages";
077 }
078
079 dynamicRequest.setParameter("tabs1", tabs1);
080
081 Group group = user.getGroup();
082
083 dynamicRequest.setParameter(
084 "groupId", String.valueOf(group.getGroupId()));
085
086 ActionUtil.getGroup(renderRequest);
087
088 return mapping.findForward("portlet.my_pages.edit_pages");
089 }
090
091 }