示例#1
0
  /**
   * Append the calendars of a list of groups. The groups must have their calendar tool enabled,
   * this routine doesn't check it.
   *
   * @param ureq
   * @param groups
   * @param isOwner
   * @param calendars
   */
  private void addCalendars(
      List<BusinessGroup> groups,
      boolean isOwner,
      boolean isParticipant,
      List<KalendarRenderWrapper> calendars,
      Map<CalendarKey, CalendarUserConfiguration> configMap) {

    Map<Long, Long> groupKeyToAccess =
        CoreSpringFactory.getImpl(CollaborationManager.class).lookupCalendarAccess(groups);
    for (BusinessGroup bGroup : groups) {
      KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
      groupCalendarWrapper.setPrivateEventsVisible(true);
      // set calendar access
      int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
      Long lCalAccess = groupKeyToAccess.get(bGroup.getKey());
      if (lCalAccess != null) {
        iCalAccess = lCalAccess.intValue();
      }
      if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
      } else {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
      }
      CalendarUserConfiguration config = configMap.get(groupCalendarWrapper.getCalendarKey());
      if (config != null) {
        groupCalendarWrapper.setConfiguration(config);
      }
      if (isOwner || isParticipant) {
        groupCalendarWrapper.setPrivateEventsVisible(true);
      }
      calendars.add(groupCalendarWrapper);
    }
  }