Search in sources :

Example 86 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper 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 87 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarPersonalConfigurationController method doToogleAggregated.

private void doToogleAggregated(UserRequest ureq, CalendarPersonalConfigurationRow row) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setInAggregatedFeed(!calendarWrapper.isInAggregatedFeed());
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    enableDisableIcons(row.getAggregatedLink(), calendarWrapper.isInAggregatedFeed());
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 88 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarPersonalConfigurationController method doDeleteToken.

private void doDeleteToken(CalendarPersonalConfigurationRow row) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setToken(null);
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    tableEl.reloadData();
}
Also used : KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 89 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarPersonalConfigurationController method doSetColor.

private void doSetColor(UserRequest ureq, CalendarPersonalConfigurationRow row, String cssColor) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setCssClass(cssColor);
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    row.getColorLink().setIconLeftCSS("o_cal_config_color ".concat(row.getCssClass()));
    fireEvent(ureq, new CalendarGUISettingEvent(calendarWrapper));
}
Also used : CalendarGUISettingEvent(org.olat.commons.calendar.ui.events.CalendarGUISettingEvent) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 90 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarPersonalConfigurationController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (allowImport) {
        importTypeFileButton = uifactory.addFormLink("cal.import.type.file", formLayout, Link.BUTTON);
        importTypeFileButton.setIconLeftCSS("o_icon o_icon_import");
        importTypeUrlButton = uifactory.addFormLink("cal.synchronize.type.url", formLayout, Link.BUTTON);
        importTypeUrlButton.setIconLeftCSS("o_icon o_icon_calendar_sync");
    }
    // add the table
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ConfigCols.type.i18nKey(), ConfigCols.type.ordinal(), true, ConfigCols.type.name(), new CalendarTypeClassRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ConfigCols.cssClass.i18nKey(), ConfigCols.cssClass.ordinal(), true, ConfigCols.cssClass.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ConfigCols.name.i18nKey(), ConfigCols.name.ordinal(), true, ConfigCols.name.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ConfigCols.visible.i18nKey(), ConfigCols.visible.ordinal(), true, ConfigCols.visible.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ConfigCols.aggregated.i18nKey(), ConfigCols.aggregated.ordinal(), true, ConfigCols.aggregated.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ConfigCols.feed.i18nKey(), ConfigCols.feed.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ConfigCols.tools.i18nKey(), ConfigCols.tools.ordinal()));
    model = new CalendarPersonalConfigurationDataModel(columnsModel);
    List<CalendarPersonalConfigurationRow> rows = new ArrayList<>(calendars.size());
    for (KalendarRenderWrapper calendar : calendars) {
        CalendarPersonalConfigurationRow row = new CalendarPersonalConfigurationRow(calendar);
        initLinks(row);
        rows.add(row);
    }
    model.setObjects(rows);
    tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
    tableEl.setMultiSelect(false);
    tableEl.setPageSize(50);
    tableEl.setCustomizeColumns(false);
    tableEl.setNumOfRowsEnabled(false);
}
Also used : ArrayList(java.util.ArrayList) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Aggregations

KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)134 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)46 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 Identity (org.olat.core.id.Identity)26 Date (java.util.Date)24 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)24 Calendar (java.util.Calendar)22 Kalendar (org.olat.commons.calendar.model.Kalendar)22 ICourse (org.olat.course.ICourse)20 File (java.io.File)18 BusinessGroup (org.olat.group.BusinessGroup)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 CalendarImportTest (org.olat.commons.calendar.CalendarImportTest)14 URL (java.net.URL)12 EventVO (org.olat.commons.calendar.restapi.EventVO)12 CalendarManager (org.olat.commons.calendar.CalendarManager)10 HttpGet (org.apache.http.client.methods.HttpGet)8 UserRequest (org.olat.core.gui.UserRequest)8