Search in sources :

Example 1 with CalendarModule

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;
}
Also used : UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CalWebService(org.olat.commons.calendar.restapi.CalWebService) CalendarModule(org.olat.commons.calendar.CalendarModule) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path)

Example 2 with CalendarModule

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);
}
Also used : ArrayList(java.util.ArrayList) PortfolioV2Module(org.olat.modules.portfolio.PortfolioV2Module) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) CalendarModule(org.olat.commons.calendar.CalendarModule) OpenMeetingsModule(org.olat.modules.openmeetings.OpenMeetingsModule) InstantMessagingModule(org.olat.instantMessaging.InstantMessagingModule) PortfolioModule(org.olat.portfolio.PortfolioModule)

Example 3 with CalendarModule

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;
}
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 CalendarModule

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);
            }
        }
    }
}
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 5 with CalendarModule

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;
}
Also used : UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CalWebService(org.olat.commons.calendar.restapi.CalWebService) CalendarModule(org.olat.commons.calendar.CalendarModule) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path)

Aggregations

CalendarModule (org.olat.commons.calendar.CalendarModule)8 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)6 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)6 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)6 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)6 CollaborationManager (org.olat.collaboration.CollaborationManager)4 Identity (org.olat.core.id.Identity)4 ICourse (org.olat.course.ICourse)4 BusinessGroup (org.olat.group.BusinessGroup)4 BusinessGroupService (org.olat.group.BusinessGroupService)4 ArrayList (java.util.ArrayList)2 Path (javax.ws.rs.Path)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 BaseSecurityModule (org.olat.basesecurity.BaseSecurityModule)2 CalWebService (org.olat.commons.calendar.restapi.CalWebService)2 UserRequest (org.olat.core.gui.UserRequest)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