use of org.olat.course.run.calendar.CourseLinkProviderController in project openolat by klemens.
the class CourseCalendars method createCourseCalendarsWrapper.
public static CourseCalendars createCourseCalendarsWrapper(UserRequest ureq, WindowControl wControl, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
List<KalendarRenderWrapper> calendars = new ArrayList<>();
ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
KalendarRenderWrapper courseKalendarWrapper = getCourseCalendarWrapper(ureq, courseEnv, ne);
// add link provider
CourseLinkProviderController clpc = new CourseLinkProviderController(course, Collections.singletonList(course), ureq, wControl);
courseKalendarWrapper.setLinkProvider(clpc);
calendars.add(courseKalendarWrapper);
Identity identity = ureq.getIdentity();
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
// add course group calendars
boolean isGroupManager = ureq.getUserSession().getRoles().isOLATAdmin() || ureq.getUserSession().getRoles().isGroupManager() || cgm.isIdentityCourseAdministrator(identity) || cgm.hasRight(identity, CourseRights.RIGHT_GROUPMANAGEMENT);
boolean readOnly = courseEnv.isCourseReadOnly();
if (isGroupManager) {
// learning groups
List<BusinessGroup> allGroups = cgm.getAllBusinessGroups();
addCalendars(ureq, courseEnv, allGroups, !readOnly, clpc, calendars);
} else {
// learning groups
List<BusinessGroup> ownerGroups = cgm.getOwnedBusinessGroups(identity);
addCalendars(ureq, courseEnv, ownerGroups, !readOnly, clpc, calendars);
List<BusinessGroup> attendedGroups = cgm.getParticipatingBusinessGroups(identity);
for (BusinessGroup ownerGroup : ownerGroups) {
if (attendedGroups.contains(ownerGroup)) {
attendedGroups.remove(ownerGroup);
}
}
addCalendars(ureq, courseEnv, attendedGroups, false, clpc, calendars);
}
return new CourseCalendars(courseKalendarWrapper, calendars);
}
Aggregations