Search in sources :

Example 36 with CalendarUserConfiguration

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

the class ICalFileCalendarManager method saveCalendarConfigForIdentity.

@Override
public void saveCalendarConfigForIdentity(KalendarRenderWrapper wrapper, Identity identity) {
    Kalendar calendar = wrapper.getKalendar();
    CalendarUserConfiguration configuration = calendarUserConfigDao.getCalendarUserConfiguration(identity, calendar.getCalendarID(), calendar.getType());
    if (configuration == null) {
        configuration = calendarUserConfigDao.createCalendarUserConfiguration(wrapper.getKalendar(), identity, wrapper.getToken(), wrapper.isInAggregatedFeed(), wrapper.isVisible());
    } else {
        configuration.setVisible(wrapper.isVisible());
        configuration.setCssClass(wrapper.getCssClass());
        configuration.setToken(wrapper.getToken());
        configuration.setInAggregatedFeed(wrapper.isInAggregatedFeed());
        configuration = calendarUserConfigDao.update(configuration);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration)

Example 37 with CalendarUserConfiguration

use of org.olat.commons.calendar.model.CalendarUserConfiguration 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 38 with CalendarUserConfiguration

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

the class CollaborationManagerImpl method getCalendar.

@Override
public KalendarRenderWrapper getCalendar(BusinessGroup businessGroup, UserRequest ureq, boolean isAdmin) {
    // do not use a global translator since in the fututre a collaborationtools
    // may be shared among users
    // get the calendar
    KalendarRenderWrapper calRenderWrapper = calendarManager.getGroupCalendar(businessGroup);
    boolean isOwner = businessGroupService.hasRoles(ureq.getIdentity(), businessGroup, GroupRoles.coach.name());
    if (!(isAdmin || isOwner)) {
        // check if participants have read/write access
        int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
        Long lCalAccess = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup).lookupCalendarAccess();
        if (lCalAccess != null)
            iCalAccess = lCalAccess.intValue();
        if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_ALL) {
            calRenderWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        } else {
            calRenderWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        }
    } else {
        calRenderWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
    }
    CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(calRenderWrapper.getKalendar(), ureq.getIdentity());
    if (config != null) {
        calRenderWrapper.setConfiguration(config);
    }
    return calRenderWrapper;
}
Also used : CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 39 with CalendarUserConfiguration

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

the class WeeklyCalendarController method getAggregatedCalendarUrl.

private String getAggregatedCalendarUrl() {
    List<CalendarUserConfiguration> configurations = calendarManager.getCalendarUserConfigurationsList(getIdentity(), CalendarManager.TYPE_USER_AGGREGATED);
    CalendarUserConfiguration config;
    if (configurations.isEmpty()) {
        config = calendarManager.createAggregatedCalendarConfig(getIdentity());
    } else if (StringHelper.containsNonWhitespace(configurations.get(0).getToken())) {
        config = configurations.get(0);
    } else {
        config = configurations.get(0);
        config.setToken(RandomStringUtils.randomAlphanumeric(6));
        config = calendarManager.saveCalendarConfig(config);
    }
    return Settings.getServerContextPathURI() + "/ical/" + CalendarManager.TYPE_USER_AGGREGATED + "/" + config.getKey() + "/" + config.getToken() + ".ics";
}
Also used : CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration)

Example 40 with CalendarUserConfiguration

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

the class CourseCalendars method getCourseCalendarWrapper.

/**
 * Return only the course calendar without any group calendar
 * @param ureq
 * @param wControl
 * @param ores
 * @param ne
 * @return
 */
public static KalendarRenderWrapper getCourseCalendarWrapper(UserRequest ureq, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
    CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
    // add course calendar
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
    KalendarRenderWrapper courseKalendarWrapper = calendarManager.getCourseCalendar(course);
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    Identity identity = ureq.getIdentity();
    Roles roles = ureq.getUserSession().getRoles();
    boolean isPrivileged = !courseEnv.isCourseReadOnly() && (roles.isOLATAdmin() || courseEnv.isAdmin() || (ne != null && ne.isCapabilityAccessible(CalCourseNode.EDIT_CONDITION_ID)) || RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(identity, roles, cgm.getCourseEntry()));
    if (isPrivileged) {
        courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        courseKalendarWrapper.setPrivateEventsVisible(true);
    } else {
        courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        courseKalendarWrapper.setPrivateEventsVisible(courseEnv.isAdmin() || courseEnv.isCoach() || courseEnv.isParticipant());
    }
    CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(courseKalendarWrapper.getKalendar(), ureq.getIdentity());
    if (config != null) {
        courseKalendarWrapper.setConfiguration(config);
    }
    return courseKalendarWrapper;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CalendarManager(org.olat.commons.calendar.CalendarManager) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) Identity(org.olat.core.id.Identity)

Aggregations

CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)46 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)24 Kalendar (org.olat.commons.calendar.model.Kalendar)12 Identity (org.olat.core.id.Identity)12 ArrayList (java.util.ArrayList)10 BusinessGroup (org.olat.group.BusinessGroup)10 CalendarKey (org.olat.commons.calendar.model.CalendarKey)8 Test (org.junit.Test)6 CalendarManager (org.olat.commons.calendar.CalendarManager)6 CorruptedCourseException (org.olat.course.CorruptedCourseException)6 ICourse (org.olat.course.ICourse)6 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 CollaborationTools (org.olat.collaboration.CollaborationTools)4 CollaborationToolsFactory (org.olat.collaboration.CollaborationToolsFactory)4 Roles (org.olat.core.id.Roles)4 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2