use of org.olat.commons.calendar.CalendarModule in project OpenOLAT by OpenOLAT.
the class CourseWebService method getCourseCalendarWebService.
@Path("calendar")
public CalWebService getCourseCalendarWebService(@Context HttpServletRequest request) {
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled() && (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) && course.getCourseConfig().isCalendarEnabled()) {
UserRequest ureq = getUserRequest(request);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(ureq.getIdentity());
ienv.setRoles(ureq.getUserSession().getRoles());
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
return new CalWebService(wrapper);
}
return null;
}
use of org.olat.commons.calendar.CalendarModule in project OpenOLAT by OpenOLAT.
the class CollaborationToolsFactory method initAvailableTools.
/**
* Helper method to initialize the list of enabled tools based system wide
* configuration.
*/
public synchronized void initAvailableTools() {
ArrayList<String> toolArr = new ArrayList<String>();
toolArr.add(CollaborationTools.TOOL_NEWS);
toolArr.add(CollaborationTools.TOOL_CONTACT);
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled() && calendarModule.isEnableGroupCalendar()) {
toolArr.add(CollaborationTools.TOOL_CALENDAR);
}
toolArr.add(CollaborationTools.TOOL_FOLDER);
toolArr.add(CollaborationTools.TOOL_FORUM);
if (CoreSpringFactory.getImpl(InstantMessagingModule.class).isEnabled()) {
toolArr.add(CollaborationTools.TOOL_CHAT);
}
BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
if (securityModule.isWikiEnabled()) {
toolArr.add(CollaborationTools.TOOL_WIKI);
}
PortfolioModule portfolioModule = CoreSpringFactory.getImpl(PortfolioModule.class);
PortfolioV2Module portfolioV2Module = CoreSpringFactory.getImpl(PortfolioV2Module.class);
if (portfolioModule.isEnabled() || portfolioV2Module.isEnabled()) {
toolArr.add(CollaborationTools.TOOL_PORTFOLIO);
}
OpenMeetingsModule openMeetingsModule = CoreSpringFactory.getImpl(OpenMeetingsModule.class);
if (openMeetingsModule.isEnabled()) {
toolArr.add(CollaborationTools.TOOL_OPENMEETINGS);
}
TOOLS = ArrayHelper.toArray(toolArr);
}
use of org.olat.commons.calendar.CalendarModule 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.commons.calendar.CalendarModule 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.commons.calendar.CalendarModule in project openolat by klemens.
the class CourseWebService method getCourseCalendarWebService.
@Path("calendar")
public CalWebService getCourseCalendarWebService(@Context HttpServletRequest request) {
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled() && (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) && course.getCourseConfig().isCalendarEnabled()) {
UserRequest ureq = getUserRequest(request);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(ureq.getIdentity());
ienv.setRoles(ureq.getUserSession().getRoles());
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
return new CalWebService(wrapper);
}
return null;
}
Aggregations