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);
}
}
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;
}
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;
}
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";
}
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;
}
Aggregations