Search in sources :

Example 6 with CalendarKey

use of org.olat.commons.calendar.model.CalendarKey in project openolat by klemens.

the class ICalFileCalendarManager method getCalendarUserConfigurationsMap.

@Override
public Map<CalendarKey, CalendarUserConfiguration> getCalendarUserConfigurationsMap(IdentityRef identity, String... types) {
    List<CalendarUserConfiguration> list = calendarUserConfigDao.getCalendarUserConfigurations(identity, types);
    Map<CalendarKey, CalendarUserConfiguration> map = new HashMap<>();
    for (CalendarUserConfiguration config : list) {
        map.put(new CalendarKey(config.getCalendarId(), config.getType()), config);
    }
    return map;
}
Also used : CalendarKey(org.olat.commons.calendar.model.CalendarKey) HashMap(java.util.HashMap) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration)

Example 7 with CalendarKey

use of org.olat.commons.calendar.model.CalendarKey in project openolat by klemens.

the class CourseCalendars method addCalendars.

private static void addCalendars(UserRequest ureq, UserCourseEnvironment courseEnv, List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
    if (groups == null || groups.isEmpty())
        return;
    CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
    CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
    Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(ureq.getIdentity(), CalendarManager.TYPE_GROUP);
    for (BusinessGroup bGroup : groups) {
        CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
        if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) {
            continue;
        }
        boolean member = courseEnv.isIdentityInCourseGroup(bGroup.getKey());
        KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
        groupCalendarWrapper.setPrivateEventsVisible(member || isOwner);
        // set calendar access
        int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
        Long lCalAccess = collabTools.lookupCalendarAccess();
        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);
        }
        groupCalendarWrapper.setLinkProvider(linkProvider);
        calendars.add(groupCalendarWrapper);
    }
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarKey(org.olat.commons.calendar.model.CalendarKey) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

Example 8 with CalendarKey

use of org.olat.commons.calendar.model.CalendarKey in project openolat by klemens.

the class HomeCalendarManager method getListOfCalendarWrappers.

@Override
public List<KalendarRenderWrapper> getListOfCalendarWrappers(UserRequest ureq, WindowControl wControl) {
    if (!calendarModule.isEnabled()) {
        return new ArrayList<KalendarRenderWrapper>();
    }
    Identity identity = ureq.getIdentity();
    List<KalendarRenderWrapper> calendars = new ArrayList<KalendarRenderWrapper>();
    Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(ureq.getIdentity());
    appendPersonalCalendar(identity, calendars, configMap);
    appendGroupCalendars(identity, calendars, configMap);
    appendCourseCalendars(ureq, wControl, calendars, configMap);
    // reload every hour
    List<KalendarRenderWrapper> importedCalendars = importCalendarManager.getImportedCalendarsForIdentity(identity, true);
    for (KalendarRenderWrapper importedCalendar : importedCalendars) {
        importedCalendar.setPrivateEventsVisible(true);
    }
    calendars.addAll(importedCalendars);
    return calendars;
}
Also used : CalendarKey(org.olat.commons.calendar.model.CalendarKey) ArrayList(java.util.ArrayList) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) Identity(org.olat.core.id.Identity) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Aggregations

CalendarKey (org.olat.commons.calendar.model.CalendarKey)8 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)8 ArrayList (java.util.ArrayList)4 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)4 BusinessGroup (org.olat.group.BusinessGroup)4 File (java.io.File)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 CollaborationToolsFactory (org.olat.collaboration.CollaborationToolsFactory)2 CalendarManager (org.olat.commons.calendar.CalendarManager)2 CalendarFileInfos (org.olat.commons.calendar.model.CalendarFileInfos)2 Identity (org.olat.core.id.Identity)2 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2