use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class CalendarEntryDetailsController method doSave.
private void doSave(UserRequest ureq) {
// ok, save edited entry
kalendarEvent = eventForm.getUpdatedKalendarEvent();
if (isNew) {
boolean doneSuccessfully = true;
// this is a new event, add event to calendar
String calendarID = eventForm.getChoosenKalendarID();
for (Iterator<KalendarRenderWrapper> iter = availableCalendars.iterator(); iter.hasNext(); ) {
KalendarRenderWrapper calendarWrapper = iter.next();
if (!calendarWrapper.getKalendar().getCalendarID().equals(calendarID)) {
continue;
}
Kalendar cal = calendarWrapper.getKalendar();
boolean result = calendarManager.addEventTo(cal, kalendarEvent);
if (result == false) {
// if one failed => done not successfully
doneSuccessfully = false;
}
}
reportSaveStatus(ureq, doneSuccessfully);
} else if (kalendarEvent instanceof KalendarRecurEvent && !StringHelper.containsNonWhitespace(kalendarEvent.getRecurrenceID())) {
updateCtr = new ConfirmUpdateController(ureq, getWindowControl(), (KalendarRecurEvent) kalendarEvent);
listenTo(updateCtr);
String title = translate("cal.edit.update");
cmc = new CloseableModalController(getWindowControl(), translate("close"), updateCtr.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
} else {
// this is an existing event, so we get the previousely assigned calendar from the event
Kalendar cal = kalendarEvent.getCalendar();
boolean doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
reportSaveStatus(ureq, doneSuccessfully);
}
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class WeeklyCalendarController method getCallerKalendarRenderWrapper.
private KalendarRenderWrapper getCallerKalendarRenderWrapper() {
if (callerOres == null || calendarWrappers == null)
return null;
String callerResId = callerOres.getResourceableId().toString();
for (KalendarRenderWrapper calendarWrapper : calendarWrappers) {
String calendarType = calendarWrapper.getKalendar().getType();
String calendarId = calendarWrapper.getKalendar().getCalendarID();
if (callerResId.equals(calendarId)) {
if ((WeeklyCalendarController.CALLER_COLLAB.equals(caller) && CalendarManager.TYPE_GROUP.equals(calendarType)) || (WeeklyCalendarController.CALLER_COURSE.equals(caller) && CalendarManager.TYPE_COURSE.equals(calendarType))) {
return calendarWrapper;
}
} else if ((WeeklyCalendarController.CALLER_PROFILE.equals(caller) || WeeklyCalendarController.CALLER_HOME.equals(caller)) && CalendarManager.TYPE_USER.equals(calendarType) && calendarId.equals(callerOres.getResourceableTypeName())) {
return calendarWrapper;
}
}
return null;
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class WeeklyCalendarController method pushEditEventController.
/**
* @param ureq
* @param kalendarEvent
* @param kalendarWrapper
*/
private void pushEditEventController(UserRequest ureq, KalendarEvent kalendarEvent, KalendarRenderWrapper kalendarWrapper) {
if (editController != null)
return;
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(editController);
boolean canEdit = false;
for (Iterator<KalendarRenderWrapper> iter = calendarWrappers.iterator(); iter.hasNext(); ) {
KalendarRenderWrapper wrapper = iter.next();
if (wrapper.getAccess() == KalendarRenderWrapper.ACCESS_READ_WRITE && kalendarWrapper.getKalendar().getCalendarID().equals(wrapper.getKalendar().getCalendarID())) {
canEdit = true;
}
}
if (canEdit) {
editController = new CalendarEntryDetailsController(ureq, kalendarEvent, kalendarWrapper, calendarWrappers, false, caller, getWindowControl());
listenTo(editController);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), editController.getInitialComponent());
listenTo(cmc);
cmc.activate();
// set logging action
setCalLoggingAction(CalendarLoggingAction.CALENDAR_ENTRY_MODIFIED);
} else {
showError("cal.error.readonly");
}
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class CourseCalendars method createCourseCalendarsWrapper.
public static CourseCalendars createCourseCalendarsWrapper(UserRequest ureq, WindowControl wControl, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
List<KalendarRenderWrapper> calendars = new ArrayList<>();
ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
KalendarRenderWrapper courseKalendarWrapper = getCourseCalendarWrapper(ureq, courseEnv, ne);
// add link provider
CourseLinkProviderController clpc = new CourseLinkProviderController(course, Collections.singletonList(course), ureq, wControl);
courseKalendarWrapper.setLinkProvider(clpc);
calendars.add(courseKalendarWrapper);
Identity identity = ureq.getIdentity();
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
// add course group calendars
boolean isGroupManager = ureq.getUserSession().getRoles().isOLATAdmin() || ureq.getUserSession().getRoles().isGroupManager() || cgm.isIdentityCourseAdministrator(identity) || cgm.hasRight(identity, CourseRights.RIGHT_GROUPMANAGEMENT);
boolean readOnly = courseEnv.isCourseReadOnly();
if (isGroupManager) {
// learning groups
List<BusinessGroup> allGroups = cgm.getAllBusinessGroups();
addCalendars(ureq, courseEnv, allGroups, !readOnly, clpc, calendars);
} else {
// learning groups
List<BusinessGroup> ownerGroups = cgm.getOwnedBusinessGroups(identity);
addCalendars(ureq, courseEnv, ownerGroups, !readOnly, clpc, calendars);
List<BusinessGroup> attendedGroups = cgm.getParticipatingBusinessGroups(identity);
for (BusinessGroup ownerGroup : ownerGroups) {
if (attendedGroups.contains(ownerGroup)) {
attendedGroups.remove(ownerGroup);
}
}
addCalendars(ureq, courseEnv, attendedGroups, false, clpc, calendars);
}
return new CourseCalendars(courseKalendarWrapper, calendars);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class CourseCalendars method addCalendars.
private static void addCalendars(UserRequest ureq, UserCourseEnvironment courseEnv, List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
if (groups == null || groups.isEmpty())
return;
CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(ureq.getIdentity(), CalendarManager.TYPE_GROUP);
for (BusinessGroup bGroup : groups) {
CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) {
continue;
}
boolean member = courseEnv.isIdentityInCourseGroup(bGroup.getKey());
KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
groupCalendarWrapper.setPrivateEventsVisible(member || isOwner);
// set calendar access
int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
Long lCalAccess = collabTools.lookupCalendarAccess();
if (lCalAccess != null)
iCalAccess = lCalAccess.intValue();
if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
} else {
groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
}
CalendarUserConfiguration config = configMap.get(groupCalendarWrapper.getCalendarKey());
if (config != null) {
groupCalendarWrapper.setConfiguration(config);
}
groupCalendarWrapper.setLinkProvider(linkProvider);
calendars.add(groupCalendarWrapper);
}
}
Aggregations