示例#1
1
  protected static List<CalendarBooking> filterCalendarBookings(
      List<CalendarBooking> calendarBookings, PermissionChecker permissionChecker, String actionId)
      throws PortalException, SystemException {

    calendarBookings = ListUtil.copy(calendarBookings);

    Iterator<CalendarBooking> itr = calendarBookings.iterator();

    while (itr.hasNext()) {
      CalendarBooking calendarBooking = itr.next();

      if (!CalendarPermission.contains(
          permissionChecker, calendarBooking.getCalendarId(), ACTION_VIEW_BOOKING_DETAILS)) {

        if (!CalendarPermission.contains(
            permissionChecker, calendarBooking.getCalendarId(), actionId)) {

          itr.remove();
        } else {
          filterCalendarBooking(calendarBooking, permissionChecker);
        }
      }
    }

    return calendarBookings;
  }
示例#2
1
  public static List<Calendar> getAllCalendars(PermissionChecker permissionChecker)
      throws PortalException, SystemException {

    List<Calendar> calendars = new ArrayList<Calendar>();

    calendars = new ArrayList<Calendar>();

    if (PortletPropsValues.PROPFIND_PROVIDE_SESSIONCLICKS_CALENDARS) {
      calendars.addAll(getUserCalendars(permissionChecker.getUserId()));

      calendars.addAll(getUserGroupCalendars(permissionChecker));

      calendars.addAll(getSelectedCalendars(permissionChecker.getUserId()));
    } else {
      List<Calendar> allCalendars =
          CalendarLocalServiceUtil.getCalendars(QueryUtil.ALL_POS, QueryUtil.ALL_POS);

      for (Calendar calendar : allCalendars) {
        if (CalendarPermission.contains(permissionChecker, calendar, ActionKeys.VIEW)) {

          calendars.add(calendar);
        }
      }
    }

    return calendars;
  }
示例#3
1
  public static List<Calendar> getUserGroupCalendars(PermissionChecker permissionChecker)
      throws PortalException, SystemException {

    List<Calendar> calendars = new ArrayList<Calendar>();

    long classNameId = PortalUtil.getClassNameId(Group.class.getName());

    List<CalendarResource> calendarResources =
        CalendarResourceServiceUtil.search(
            permissionChecker.getCompanyId(),
            new long[] {},
            new long[] {classNameId},
            null,
            true,
            true,
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS,
            null);

    for (CalendarResource calendarResource : calendarResources) {
      for (Calendar calendar : calendarResource.getCalendars()) {
        if (CalendarPermission.contains(permissionChecker, calendar, ActionKeys.VIEW)) {

          calendars.add(calendar);
        }
      }
    }

    return calendars;
  }
  @Override
  public boolean hasPermission(
      PermissionChecker permissionChecker,
      String entryClassName,
      long entryClassPK,
      String actionId)
      throws Exception {

    return CalendarPermission.contains(permissionChecker, entryClassPK, ActionKeys.VIEW);
  }
示例#5
0
  protected CalendarBooking filterCalendarBooking(CalendarBooking calendarBooking)
      throws PortalException, SystemException {

    if (!CalendarPermission.contains(
        getPermissionChecker(), calendarBooking.getCalendarId(), ActionKeys.VIEW_BOOKING_DETAILS)) {

      calendarBooking.setTitle(StringPool.BLANK);
      calendarBooking.setDescription(StringPool.BLANK);
      calendarBooking.setLocation(StringPool.BLANK);
    }

    return calendarBooking;
  }
示例#6
0
  protected static CalendarBooking filterCalendarBooking(
      CalendarBooking calendarBooking, PermissionChecker permissionChecker)
      throws PortalException, SystemException {

    if (!CalendarPermission.contains(
        permissionChecker, calendarBooking.getCalendarId(), ACTION_VIEW_BOOKING_DETAILS)) {

      calendarBooking.setTitle(StringPool.BLANK);
      calendarBooking.setDescription(StringPool.BLANK);
      calendarBooking.setLocation(StringPool.BLANK);
    }

    return calendarBooking;
  }
  @Override
  public boolean hasPermission(PermissionChecker permissionChecker, long classPK, String actionId)
      throws Exception {

    CalendarBooking calendarBooking = _calendarBookingLocalService.getCalendarBooking(classPK);

    if (actionId.equals(ActionKeys.DELETE) || actionId.equals(ActionKeys.UPDATE)) {

      actionId = CalendarActionKeys.MANAGE_BOOKINGS;
    }

    return CalendarPermission.contains(
        permissionChecker, calendarBooking.getCalendarId(), actionId);
  }
  protected List<Calendar> filterCalendars(List<Calendar> calendars, String actionId)
      throws PrincipalException {

    calendars = ListUtil.copy(calendars);

    Iterator<Calendar> itr = calendars.iterator();

    while (itr.hasNext()) {
      Calendar calendar = itr.next();

      if (!CalendarPermission.contains(getPermissionChecker(), calendar, actionId)) {

        itr.remove();
      }
    }

    return calendars;
  }
  @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);
  }