use of org.olat.commons.calendar.model.CalendarUserConfiguration 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);
}
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project openolat by klemens.
the class CourseCalendarController method addCalendars.
private void addCalendars(List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
for (BusinessGroup bGroup : groups) {
CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR))
continue;
KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
groupCalendarWrapper.setPrivateEventsVisible(true);
// 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 = calendarManager.findCalendarConfigForIdentity(groupCalendarWrapper.getKalendar(), getIdentity());
if (config != null) {
groupCalendarWrapper.setConfiguration(config);
}
groupCalendarWrapper.setLinkProvider(linkProvider);
calendars.add(groupCalendarWrapper);
}
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project openolat by klemens.
the class CourseCalendarController method getListOfCalendarWrappers.
private List<KalendarRenderWrapper> getListOfCalendarWrappers(UserRequest ureq) {
List<KalendarRenderWrapper> calendars = new ArrayList<>();
// add course calendar
ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
courseKalendarWrapper = calendarManager.getCourseCalendar(course);
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
Roles roles = ureq.getUserSession().getRoles();
boolean isPrivileged = !userCourseEnv.isCourseReadOnly() && (roles.isOLATAdmin() || userCourseEnv.isAdmin() || repositoryManager.isInstitutionalRessourceManagerFor(getIdentity(), roles, cgm.getCourseEntry()));
if (isPrivileged) {
courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
courseKalendarWrapper.setPrivateEventsVisible(true);
} else {
courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
courseKalendarWrapper.setPrivateEventsVisible(userCourseEnv.isAdmin() || userCourseEnv.isCoach() || userCourseEnv.isParticipant());
}
CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(courseKalendarWrapper.getKalendar(), getIdentity());
if (config != null) {
courseKalendarWrapper.setConfiguration(config);
}
// add link provider
CourseLinkProviderController clpc = new CourseLinkProviderController(course, Collections.<ICourse>singletonList(course), ureq, getWindowControl());
courseKalendarWrapper.setLinkProvider(clpc);
calendars.add(courseKalendarWrapper);
// add course group calendars
// learning groups
List<BusinessGroup> ownerGroups = cgm.getOwnedBusinessGroups(getIdentity());
addCalendars(ownerGroups, !userCourseEnv.isCourseReadOnly(), clpc, calendars);
List<BusinessGroup> attendedGroups = cgm.getParticipatingBusinessGroups(getIdentity());
for (Iterator<BusinessGroup> ownerGroupsIterator = ownerGroups.iterator(); ownerGroupsIterator.hasNext(); ) {
BusinessGroup ownerGroup = ownerGroupsIterator.next();
if (attendedGroups.contains(ownerGroup))
attendedGroups.remove(ownerGroup);
}
addCalendars(attendedGroups, false, clpc, calendars);
return calendars;
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration 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;
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project openolat by klemens.
the class HomeCalendarManager method addCalendars.
/**
* 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) {
try {
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);
} catch (Exception e) {
log.error("Cannot read calendar of group: " + bGroup, e);
}
}
}
Aggregations