@Override public PortletURL getURLAdd( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, long classTypeId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); CalendarResource calendarResource = CalendarResourceUtil.getScopeGroupCalendarResource( liferayPortletRequest, themeDisplay.getScopeGroupId()); if (calendarResource == null) { return null; } PortletURL portletURL = PortalUtil.getControlPanelPortletURL( liferayPortletRequest, CalendarPortletKeys.CALENDAR, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/edit_calendar_booking.jsp"); Calendar calendar = calendarResource.getDefaultCalendar(); portletURL.setParameter("calendarId", String.valueOf(calendar.getCalendarId())); return portletURL; }
@Override public boolean hasAddPermission( PermissionChecker permissionChecker, long groupId, long classTypeId) throws Exception { ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(permissionChecker.getCompanyId()); CalendarResource calendarResource = CalendarResourceUtil.getScopeGroupCalendarResource(groupId, serviceContext); if (calendarResource == null) { return false; } Calendar calendar = calendarResource.getDefaultCalendar(); return CalendarPermission.contains( permissionChecker, calendar.getCalendarId(), CalendarActionKeys.MANAGE_BOOKINGS); }