List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPermissionChecker
@JSON(include = false)
public PermissionChecker getPermissionChecker()
From source file:com.liferay.site.navigation.site.map.web.internal.display.context.SiteNavigationSiteMapDisplayContext.java
License:Open Source License
private void _buildSiteMap(Layout layout, List<Layout> layouts, Layout rootLayout, boolean includeRootInTree, int displayDepth, boolean showCurrentPage, boolean useHtmlTitle, boolean showHiddenPages, int curDepth, ThemeDisplay themeDisplay, StringBundler sb) throws Exception { if (layouts.isEmpty()) { return;//from w ww . j av a 2s. c om } if ((rootLayout != null) && !LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), rootLayout, ActionKeys.VIEW)) { return; } sb.append("<ul>"); if (includeRootInTree && (rootLayout != null) && (curDepth == 1)) { sb.append("<li>"); String cssClass = "root"; if (rootLayout.getPlid() == layout.getPlid()) { cssClass += " current"; } _buildLayoutView(rootLayout, cssClass, useHtmlTitle, themeDisplay, sb); _buildSiteMap(layout, layouts, rootLayout, includeRootInTree, displayDepth, showCurrentPage, useHtmlTitle, showHiddenPages, curDepth + 1, themeDisplay, sb); sb.append("</li>"); } else { for (Layout curLayout : layouts) { if ((showHiddenPages || !curLayout.isHidden()) && LayoutPermissionUtil .contains(themeDisplay.getPermissionChecker(), curLayout, ActionKeys.VIEW)) { sb.append("<li>"); String cssClass = StringPool.BLANK; if (curLayout.getPlid() == layout.getPlid()) { cssClass = "current"; } _buildLayoutView(curLayout, cssClass, useHtmlTitle, themeDisplay, sb); if ((displayDepth == 0) || (displayDepth > curDepth)) { if (showHiddenPages) { _buildSiteMap(layout, curLayout.getChildren(), rootLayout, includeRootInTree, displayDepth, showCurrentPage, useHtmlTitle, showHiddenPages, curDepth + 1, themeDisplay, sb); } else { _buildSiteMap(layout, curLayout.getChildren(themeDisplay.getPermissionChecker()), rootLayout, includeRootInTree, displayDepth, showCurrentPage, useHtmlTitle, showHiddenPages, curDepth + 1, themeDisplay, sb); } } sb.append("</li>"); } } } sb.append("</ul>"); }
From source file:com.liferay.site.teams.web.internal.display.context.SiteTeamsDisplayContext.java
License:Open Source License
public boolean isShowAddButton() throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroup(), ActionKeys.MANAGE_TEAMS)) {//from www . j a v a 2s.c om return true; } return false; }
From source file:com.liferay.site.util.GroupSearchProvider.java
License:Open Source License
protected LinkedHashMap<String, Object> getGroupParams(PortletRequest portletRequest, GroupSearchTerms searchTerms, long parentGroupId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("site", Boolean.TRUE); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); User user = themeDisplay.getUser();//from ww w . jav a 2 s . com if (searchTerms.hasSearchTerms()) { if (isFilterManageableGroups(portletRequest)) { groupParams.put("groupsTree", getAllGroups(portletRequest)); } else if (parentGroupId > 0) { List<Group> groupsTree = new ArrayList<>(); Group parentGroup = _groupLocalService.getGroup(parentGroupId); groupsTree.add(parentGroup); groupParams.put("groupsTree", groupsTree); } if (!permissionChecker.isCompanyAdmin() && !GroupPermissionUtil.contains(permissionChecker, ActionKeys.VIEW)) { groupParams.put("usersGroups", Long.valueOf(user.getUserId())); } } return groupParams; }
From source file:com.liferay.site.util.GroupSearchProvider.java
License:Open Source License
protected boolean isFilterManageableGroups(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isCompanyAdmin()) { return false; }/*from ww w . j av a2s .c o m*/ if (GroupPermissionUtil.contains(permissionChecker, ActionKeys.VIEW)) { return false; } return true; }
From source file:com.liferay.site.util.GroupURLProvider.java
License:Open Source License
public String getGroupAdministrationURL(Group group, PortletRequest portletRequest) { PanelCategoryHelper panelCategoryHelper = new PanelCategoryHelper(_panelAppRegistry, _panelCategoryRegistry);/*w ww . j ava2 s. c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String portletId = panelCategoryHelper.getFirstPortletId(PanelCategoryKeys.SITE_ADMINISTRATION, themeDisplay.getPermissionChecker(), group); if (Validator.isNotNull(portletId)) { PortletURL groupAdministrationURL = _portal.getControlPanelPortletURL(portletRequest, group, portletId, 0, 0, PortletRequest.RENDER_PHASE); if (groupAdministrationURL != null) { return groupAdministrationURL.toString(); } } return null; }
From source file:com.liferay.site.util.GroupURLProvider.java
License:Open Source License
protected String getGroupURL(Group group, PortletRequest portletRequest, boolean includeStagingGroup) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String groupDisplayURL = group.getDisplayURL(themeDisplay, false); if (Validator.isNotNull(groupDisplayURL)) { return _http.removeParameter(groupDisplayURL, "p_p_id"); }//from w ww.j a va 2 s . c o m groupDisplayURL = group.getDisplayURL(themeDisplay, true); if (Validator.isNotNull(groupDisplayURL)) { return _http.removeParameter(groupDisplayURL, "p_p_id"); } if (includeStagingGroup && group.hasStagingGroup()) { try { if (GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), group, ActionKeys.VIEW_STAGING)) { return getGroupURL(group.getStagingGroup(), portletRequest); } } catch (PortalException pe) { _log.error("Unable to check permission on group " + group.getGroupId(), pe); } } return getGroupAdministrationURL(group, portletRequest); }
From source file:com.liferay.social.requests.web.internal.portlet.action.ViewMVCRenderCommand.java
License:Open Source License
protected String doRender(RenderRequest renderRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); Group group = _groupLocalService.getGroup(themeDisplay.getScopeGroupId()); User user = themeDisplay.getUser();//ww w.ja va 2 s. c om if (group.isUser()) { user = _userLocalService.getUserById(group.getClassPK()); } if (UserPermissionUtil.contains(themeDisplay.getPermissionChecker(), user.getUserId(), ActionKeys.UPDATE)) { List<SocialRequest> requests = _socialRequestLocalService.getReceiverUserRequests(user.getUserId(), SocialRequestConstants.STATUS_PENDING, 0, 100); renderRequest.setAttribute(SocialRequestsWebKeys.SOCIAL_REQUESTS, requests); } return "/view.jsp"; }
From source file:com.liferay.staging.configuration.web.internal.portlet.configuration.icon.StagingPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Group group = themeDisplay.getSiteGroup(); if (group.isStagedRemotely() || group.hasLocalOrRemoteStagingGroup()) { return false; }//from w w w.j a v a 2 s . c o m PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String rootPortletId = portletDisplay.getRootPortletId(); if (rootPortletId.equals(ExportImportPortletKeys.EXPORT) || rootPortletId.equals(ExportImportPortletKeys.EXPORT_IMPORT) || rootPortletId.equals(ExportImportPortletKeys.IMPORT) || rootPortletId.equals(StagingConfigurationPortletKeys.STAGING_CONFIGURATION) || rootPortletId.equals(StagingProcessesPortletKeys.STAGING_PROCESSES)) { return false; } if (!portletDisplay.isShowStagingIcon()) { return false; } try { return GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroup(), ActionKeys.PUBLISH_PORTLET_INFO); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return false; } }
From source file:com.liferay.staging.processes.web.internal.portlet.configuration.icon.StagingConfigurationPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { boolean showStagingConfiguration = GetterUtil .getBoolean(portletRequest.getParameter("showStagingConfiguration")); if (showStagingConfiguration) { return false; }//from w ww . ja va2s . c om ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Group group = themeDisplay.getScopeGroup(); if (!group.isStaged()) { return false; } User user = themeDisplay.getUser(); if (user.isDefaultUser()) { return false; } Group liveGroup = StagingUtil.getLiveGroup(group.getGroupId()); try { return GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), liveGroup, ActionKeys.MANAGE_STAGING); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return false; } }
From source file:com.liferay.trash.web.internal.portlet.TrashViewPortletProvider.java
License:Open Source License
@Override public PortletURL getPortletURL(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() || !_trashHelper.isTrashEnabled(themeDisplay.getScopeGroupId()) || !PortletPermissionUtil.hasControlPanelAccessPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) { return null; }/*from w w w. j a v a 2s. co m*/ PortletURL portletURL = _portal.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE); portletURL.setParameter("redirect", themeDisplay.getURLCurrent()); return portletURL; }