Search in sources :

Example 1 with CollaborationManager

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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) CalendarModule(org.olat.commons.calendar.CalendarModule) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

Example 2 with CollaborationManager

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);
            }
        }
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) BusinessGroup(org.olat.group.BusinessGroup) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) CourseTreeVisitor(org.olat.course.run.userview.CourseTreeVisitor) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) WebApplicationException(javax.ws.rs.WebApplicationException) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) CourseConfig(org.olat.course.config.CourseConfig) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) ACService(org.olat.resource.accesscontrol.ACService) AccessResult(org.olat.resource.accesscontrol.AccessResult) CalendarModule(org.olat.commons.calendar.CalendarModule) RepositoryManager(org.olat.repository.RepositoryManager) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

Example 3 with CollaborationManager

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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) CalendarModule(org.olat.commons.calendar.CalendarModule) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

Example 4 with CollaborationManager

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);
            }
        }
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) BusinessGroup(org.olat.group.BusinessGroup) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) CourseTreeVisitor(org.olat.course.run.userview.CourseTreeVisitor) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) WebApplicationException(javax.ws.rs.WebApplicationException) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) CourseConfig(org.olat.course.config.CourseConfig) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) ACService(org.olat.resource.accesscontrol.ACService) AccessResult(org.olat.resource.accesscontrol.AccessResult) CalendarModule(org.olat.commons.calendar.CalendarModule) RepositoryManager(org.olat.repository.RepositoryManager) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

Aggregations

CollaborationManager (org.olat.collaboration.CollaborationManager)4 CalendarModule (org.olat.commons.calendar.CalendarModule)4 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)4 Identity (org.olat.core.id.Identity)4 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)4 ICourse (org.olat.course.ICourse)4 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)4 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)4 BusinessGroup (org.olat.group.BusinessGroup)4 BusinessGroupService (org.olat.group.BusinessGroupService)4 WebApplicationException (javax.ws.rs.WebApplicationException)2 Roles (org.olat.core.id.Roles)2 CourseConfig (org.olat.course.config.CourseConfig)2 CourseTreeVisitor (org.olat.course.run.userview.CourseTreeVisitor)2 VisibleTreeFilter (org.olat.course.run.userview.VisibleTreeFilter)2 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryManager (org.olat.repository.RepositoryManager)2 SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)2 ACService (org.olat.resource.accesscontrol.ACService)2