use of org.olat.collaboration.CollaborationManager in project OpenOLAT by OpenOLAT.
the class UserCalendarWebService method getCalendar.
private KalendarRenderWrapper getCalendar(UserRequest ureq, String calendarId) {
int typeIndex = calendarId.indexOf('_');
if (typeIndex <= 0 || (typeIndex + 1 >= calendarId.length())) {
return null;
}
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (!calendarModule.isEnabled()) {
return null;
}
String type = calendarId.substring(0, typeIndex);
String id = calendarId.substring(typeIndex + 1);
KalendarRenderWrapper wrapper = null;
if ("group".equals(type) && calendarModule.isEnableGroupCalendar()) {
Long groupId = Long.parseLong(id);
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup group = bgs.loadBusinessGroup(groupId);
if (bgs.isIdentityInBusinessGroup(ureq.getIdentity(), group)) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
wrapper = collaborationManager.getCalendar(group, ureq, false);
}
} else if ("course".equals(type) && (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar())) {
Long courseId = Long.parseLong(id);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(ureq.getIdentity());
ienv.setRoles(ureq.getUserSession().getRoles());
ICourse course = CourseFactory.loadCourse(courseId);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
} else if ("user".equals(type) && calendarModule.isEnablePersonalCalendar()) {
if (id.equals(ureq.getIdentity().getName())) {
wrapper = getPersonalCalendar(ureq.getIdentity());
} else if (isAdmin(ureq.getHttpReq())) {
Identity identity = BaseSecurityManager.getInstance().findIdentityByName(id);
wrapper = getPersonalCalendar(identity);
}
}
return wrapper;
}
use of org.olat.collaboration.CollaborationManager in project OpenOLAT by OpenOLAT.
the class UserCalendarWebService method getCalendars.
private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
Roles roles = ureq.getUserSession().getRoles();
Identity retrievedUser = ureq.getIdentity();
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled()) {
if (calendarModule.isEnablePersonalCalendar()) {
KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
calVisitor.visit(personalWrapper);
}
if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
RepositoryManager rm = RepositoryManager.getInstance();
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
repoParams.setOnlyExplicitMember(true);
repoParams.setIdentity(retrievedUser);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(retrievedUser);
ienv.setRoles(roles);
List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
for (RepositoryEntry entry : entries) {
AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (config.isCalendarEnabled()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
} else {
CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
if (visitor.isFound()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
}
if (calendarModule.isEnableGroupCalendar()) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
// start found forums in groups
BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
params.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
for (BusinessGroup group : groups) {
KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
calVisitor.visit(wrapper);
}
}
}
}
use of org.olat.collaboration.CollaborationManager in project openolat by klemens.
the class UserCalendarWebService method getCalendar.
private KalendarRenderWrapper getCalendar(UserRequest ureq, String calendarId) {
int typeIndex = calendarId.indexOf('_');
if (typeIndex <= 0 || (typeIndex + 1 >= calendarId.length())) {
return null;
}
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (!calendarModule.isEnabled()) {
return null;
}
String type = calendarId.substring(0, typeIndex);
String id = calendarId.substring(typeIndex + 1);
KalendarRenderWrapper wrapper = null;
if ("group".equals(type) && calendarModule.isEnableGroupCalendar()) {
Long groupId = Long.parseLong(id);
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup group = bgs.loadBusinessGroup(groupId);
if (bgs.isIdentityInBusinessGroup(ureq.getIdentity(), group)) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
wrapper = collaborationManager.getCalendar(group, ureq, false);
}
} else if ("course".equals(type) && (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar())) {
Long courseId = Long.parseLong(id);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(ureq.getIdentity());
ienv.setRoles(ureq.getUserSession().getRoles());
ICourse course = CourseFactory.loadCourse(courseId);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
} else if ("user".equals(type) && calendarModule.isEnablePersonalCalendar()) {
if (id.equals(ureq.getIdentity().getName())) {
wrapper = getPersonalCalendar(ureq.getIdentity());
} else if (isAdmin(ureq.getHttpReq())) {
Identity identity = BaseSecurityManager.getInstance().findIdentityByName(id);
wrapper = getPersonalCalendar(identity);
}
}
return wrapper;
}
use of org.olat.collaboration.CollaborationManager in project openolat by klemens.
the class UserCalendarWebService method getCalendars.
private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
Roles roles = ureq.getUserSession().getRoles();
Identity retrievedUser = ureq.getIdentity();
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled()) {
if (calendarModule.isEnablePersonalCalendar()) {
KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
calVisitor.visit(personalWrapper);
}
if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
RepositoryManager rm = RepositoryManager.getInstance();
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
repoParams.setOnlyExplicitMember(true);
repoParams.setIdentity(retrievedUser);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(retrievedUser);
ienv.setRoles(roles);
List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
for (RepositoryEntry entry : entries) {
AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (config.isCalendarEnabled()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
} else {
CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
if (visitor.isFound()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
}
if (calendarModule.isEnableGroupCalendar()) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
// start found forums in groups
BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
params.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
for (BusinessGroup group : groups) {
KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
calVisitor.visit(wrapper);
}
}
}
}
Aggregations