use of org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent in project openolat by klemens.
the class CourseOptionsController method doChangeConfig.
private void doChangeConfig(UserRequest ureq) {
OLATResourceable courseOres = entry.getOlatResource();
ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
courseConfig = course.getCourseEnvironment().getCourseConfig();
boolean menuEnabled = menuEl.isSelected(0);
courseConfig.setMenuEnabled(menuEnabled);
boolean toolbarEnabled = toolbarEl.isSelected(0);
courseConfig.setToolbarEnabled(toolbarEnabled);
boolean enableSearch = searchEl.isSelected(0);
boolean updateSearch = courseConfig.isCourseSearchEnabled() != enableSearch;
courseConfig.setCourseSearchEnabled(enableSearch && toolbarEnabled);
boolean enableChat = chatEl.isSelected(0);
boolean updateChat = courseConfig.isChatEnabled() != enableChat;
courseConfig.setChatIsEnabled(enableChat && toolbarEnabled);
boolean enableCalendar = calendarEl == null ? false : calendarEl.isSelected(0);
boolean updateCalendar = courseConfig.isCalendarEnabled() != enableCalendar && calendarModule.isEnableCourseToolCalendar();
courseConfig.setCalendarEnabled(enableCalendar && toolbarEnabled);
String currentGlossarySoftKey = courseConfig.getGlossarySoftKey();
RepositoryEntry glossary = (RepositoryEntry) glossaryNameEl.getUserObject();
String newGlossarySoftKey = (glossary == null || !toolbarEnabled) ? null : glossary.getSoftkey();
boolean updateGlossary = (currentGlossarySoftKey == null && newGlossarySoftKey != null) || (currentGlossarySoftKey != null && newGlossarySoftKey == null) || (newGlossarySoftKey != null && !newGlossarySoftKey.equals(currentGlossarySoftKey));
courseConfig.setGlossarySoftKey(newGlossarySoftKey);
String currentFolderSoftKey = courseConfig.getSharedFolderSoftkey();
RepositoryEntry folder = (RepositoryEntry) folderNameEl.getUserObject();
String newFolderSoftKey = folder == null ? null : folder.getSoftkey();
boolean updateFolder = (currentFolderSoftKey == null && newFolderSoftKey != null) || (currentFolderSoftKey != null && newFolderSoftKey == null) || (currentFolderSoftKey != null && !currentFolderSoftKey.equals(newFolderSoftKey));
courseConfig.setSharedFolderSoftkey(newFolderSoftKey);
if (folderReadOnlyEl.isEnabled()) {
courseConfig.setSharedFolderReadOnlyMount(folderReadOnlyEl.isAtLeastSelected(1));
} else {
courseConfig.setSharedFolderReadOnlyMount(true);
}
CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
if (updateSearch) {
ILoggingAction loggingAction = enableSearch ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_DISABLED;
ThreadLocalUserActivityLogger.log(loggingAction, getClass());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.search, course.getResourceableId()), course);
}
if (updateChat) {
ILoggingAction loggingAction = enableChat ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_IM_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_IM_DISABLED;
ThreadLocalUserActivityLogger.log(loggingAction, getClass());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.chat, course.getResourceableId()), course);
}
if (updateCalendar) {
ILoggingAction loggingAction = enableCalendar ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_CALENDAR_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_CALENDAR_DISABLED;
ThreadLocalUserActivityLogger.log(loggingAction, getClass());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(), OresHelper.lookupType(CalendarManager.class));
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.calendar, course.getResourceableId()), course);
}
if (updateGlossary) {
ILoggingAction loggingAction = (newGlossarySoftKey == null) ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_GLOSSARY_DISABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_GLOSSARY_ENABLED;
LoggingResourceable lri = null;
if (newGlossarySoftKey != null) {
lri = LoggingResourceable.wrapNonOlatResource(StringResourceableType.glossarySoftKey, newGlossarySoftKey, newGlossarySoftKey);
} else if (currentGlossarySoftKey != null) {
lri = LoggingResourceable.wrapNonOlatResource(StringResourceableType.glossarySoftKey, currentGlossarySoftKey, currentGlossarySoftKey);
}
if (lri != null) {
ThreadLocalUserActivityLogger.log(loggingAction, getClass(), lri);
}
// remove references
List<Reference> repoRefs = referenceManager.getReferences(course);
for (Reference ref : repoRefs) {
if (ref.getUserdata().equals(GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER)) {
referenceManager.delete(ref);
}
}
// update references
if (glossary != null) {
referenceManager.addReference(course, glossary.getOlatResource(), GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER);
}
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.glossary, course.getResourceableId()), course);
}
if (updateFolder) {
List<Reference> repoRefs = referenceManager.getReferences(course);
for (Reference ref : repoRefs) {
if (ref.getUserdata().equals(SharedFolderManager.SHAREDFOLDERREF)) {
referenceManager.delete(ref);
}
}
if (folder != null) {
referenceManager.addReference(course, folder.getOlatResource(), SharedFolderManager.SHAREDFOLDERREF);
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_SHARED_FOLDER_REMOVED, getClass(), LoggingResourceable.wrapBCFile(folder.getDisplayname()));
} else {
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_SHARED_FOLDER_ADDED, getClass(), LoggingResourceable.wrapBCFile(""));
}
}
fireEvent(ureq, Event.CHANGED_EVENT);
}
Aggregations