use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class WeeklyCalendarController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
Kalendar affectedCal = null;
if (dirty) {
dirty = false;
fireEvent(ureq, new CalendarGUIModifiedEvent());
}
if (source == editController) {
affectedCal = editController.getKalendarEvent().getCalendar();
cmc.deactivate();
calendarEl.getComponent().setDirty(true);
// do logging if affectedCal not null
if (affectedCal != null) {
ThreadLocalUserActivityLogger.log(getCalLoggingAction(), getClass(), LoggingResourceable.wrap(ureq.getIdentity()), LoggingResourceable.wrap(affectedCal));
}
cleanUp();
} else if (source == eventDetailsCtr) {
if (event instanceof CalendarGUIEditEvent) {
eventCalloutCtr.deactivate();
cleanUp();
CalendarGUIEditEvent editEvent = (CalendarGUIEditEvent) event;
pushEditEventController(ureq, editEvent.getKalendarEvent(), editEvent.getKalendarRenderWrapper());
} else if (event == Event.DONE_EVENT) {
eventCalloutCtr.deactivate();
cleanUp();
}
} else if (source == updateCtr) {
if (event instanceof CalendarGUIUpdateEvent) {
doUpdate((CalendarGUIUpdateEvent) event, updateCtr.getKalendarEvent(), updateCtr.getDayDelta(), updateCtr.getMinuteDelta(), updateCtr.getAllDay(), updateCtr.getChangeBegin());
}
cmc.deactivate();
cleanUp();
} else if (source == printCtrl) {
if (event instanceof CalendarGUIPrintEvent) {
CalendarGUIPrintEvent printEvent = (CalendarGUIPrintEvent) event;
if (printEvent.getFrom() != null && printEvent.getTo() != null) {
doPrint(printEvent.getFrom(), printEvent.getTo());
}
}
eventCalloutCtr.deactivate();
cleanUp();
} else if (source == cmc) {
calendarEl.getComponent().setDirty(true);
cleanUp();
} else if (source == dbcSequence) {
if (event != Event.CANCELLED_EVENT) {
int pos = DialogBoxUIFactory.getButtonPos(event);
CalendarGUIEditEvent guiEvent = (CalendarGUIEditEvent) dbcSequence.getUserObject();
KalendarRenderWrapper kalendarWrapper = guiEvent.getKalendarRenderWrapper();
KalendarEvent kalendarEvent = guiEvent.getKalendarEvent();
if (pos == 0) {
// edit the sequence
// load the parent event of this sequence
KalendarEvent parentEvent = kalendarWrapper.getKalendar().getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
pushEditEventController(ureq, parentEvent, kalendarWrapper);
} else if (pos == 1) {
// delete a single event of the sequence
deleteSingleYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext"), deleteSingleYesNoController);
deleteSingleYesNoController.setUserObject(kalendarEvent);
} else if (pos == 2) {
// delete the whole sequence
deleteSequenceYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext.sequence"), deleteSequenceYesNoController);
deleteSequenceYesNoController.setUserObject(kalendarEvent);
}
}
dbcSequence.dispose();
} else if (source == deleteSingleYesNoController) {
if (DialogBoxUIFactory.isYesEvent(event)) {
KalendarEvent kalendarEvent = (KalendarEvent) deleteSingleYesNoController.getUserObject();
affectedCal = kalendarEvent.getCalendar();
KalendarEvent kEvent = affectedCal.getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
kEvent.addRecurrenceExc(kalendarEvent.getBegin());
calendarManager.updateEventFrom(affectedCal, kEvent);
deleteSingleYesNoController.dispose();
calendarEl.getComponent().setDirty(true);
}
} else if (source == deleteSequenceYesNoController) {
if (DialogBoxUIFactory.isYesEvent(event)) {
KalendarEvent kalendarEvent = (KalendarEvent) deleteSequenceYesNoController.getUserObject();
affectedCal = kalendarEvent.getCalendar();
calendarManager.removeEventFrom(affectedCal, kalendarEvent);
deleteSequenceYesNoController.dispose();
calendarEl.getComponent().setDirty(true);
}
} else if (configurationCtrl == source) {
if (event instanceof CalendarGUIImportEvent) {
CalendarGUIImportEvent importEvent = (CalendarGUIImportEvent) event;
calendarWrappers.add(importEvent.getCalendar());
calendarEl.setCalendars(calendarWrappers);
} else if (event instanceof CalendarGUIRemoveEvent) {
CalendarGUIRemoveEvent removeEvent = (CalendarGUIRemoveEvent) event;
calendarWrappers.remove(removeEvent.getCalendar());
calendarEl.setCalendars(calendarWrappers);
} else if (event instanceof CalendarGUISettingEvent) {
calendarEl.setCalendars(calendarWrappers);
}
} else if (eventCalloutCtr == source) {
cleanUp();
} else if (eventDetailsCtr == source) {
}
if (calendarEl.getComponent().isDirty()) {
if (subsContext != null) {
// group or course calendar -> prepared subscription context is the right one
NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
} else if (caller.equals(CALLER_HOME) && affectedCal != null) {
// one can add/edit/remove dates of group and course calendars from the home calendar view -> choose right subscription context
for (KalendarRenderWrapper calWrapper : calendarWrappers) {
if (affectedCal == calWrapper.getKalendar()) {
SubscriptionContext tmpSubsContext = calendarNotificationsManager.getSubscriptionContext(calWrapper);
NotificationsManager.getInstance().markPublisherNews(tmpSubsContext, ureq.getIdentity(), true);
}
}
}
}
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class InfoSubscriptionManagerImpl method getInfoSubscriber.
@Override
public Subscriber getInfoSubscriber(Identity identity, OLATResourceable resource, String subPath) {
SubscriptionContext context = getInfoSubscriptionContext(resource, subPath);
Publisher publisher = notificationsManager.getPublisher(context);
if (publisher == null) {
return null;
}
return notificationsManager.getSubscriber(identity, publisher);
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class InfoSubscriptionManagerImpl method markPublisherNews.
@Override
public void markPublisherNews(OLATResourceable resource, String subPath) {
SubscriptionContext context = getInfoSubscriptionContext(resource, subPath);
notificationsManager.markPublisherNews(context, null, true);
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class CalendarNotificationManagerImpl method getSubscriptionContext.
@Override
public SubscriptionContext getSubscriptionContext(KalendarRenderWrapper kalendarRenderWrapper) {
String caller = kalendarRenderWrapper.getKalendar().getType();
SubscriptionContext subsContext = null;
if (caller.equals(CalendarController.CALLER_COURSE) || caller.equals(CalendarManager.TYPE_COURSE)) {
Long courseId = kalendarRenderWrapper.getLinkProvider().getControler().getCourseId();
subsContext = new SubscriptionContext(OresHelper.calculateTypeName(CalendarManager.class) + "." + CalendarManager.TYPE_COURSE, courseId, CalendarController.ACTION_CALENDAR_COURSE);
}
if (caller.equals(CalendarController.CALLER_COLLAB) || caller.equals(CalendarManager.TYPE_GROUP)) {
BusinessGroup businessGroup = getBusinessGroup(kalendarRenderWrapper);
if (businessGroup != null) {
subsContext = new SubscriptionContext(OresHelper.calculateTypeName(CalendarManager.class) + "." + CalendarManager.TYPE_GROUP, businessGroup.getResourceableId(), CalendarController.ACTION_CALENDAR_GROUP);
}
}
return subsContext;
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class CollaborationTools method createForumController.
/**
* @param ureq
* @param wControl
* @param isAdmin
* @param subsContext the subscriptioncontext if subscriptions to this forum
* should be possible
* @return a forum controller
*/
public Controller createForumController(UserRequest ureq, WindowControl wControl, boolean isAdmin, boolean isGuestOnly, final SubscriptionContext subsContext) {
final boolean isAdm = isAdmin;
final boolean isGuest = isGuestOnly;
Forum forum = getForum();
Translator trans = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
TitleInfo titleInfo = new TitleInfo(null, trans.translate("collabtools.named.hasForum"));
titleInfo.setSeparatorEnabled(true);
Controller forumController = ForumUIFactory.getTitledForumController(ureq, wControl, forum, new ForumCallback() {
@Override
public boolean mayUsePseudonym() {
return false;
}
@Override
public boolean mayOpenNewThread() {
return true;
}
@Override
public boolean mayReplyMessage() {
return true;
}
@Override
public boolean mayEditOwnMessage() {
return true;
}
@Override
public boolean mayDeleteOwnMessage() {
return true;
}
@Override
public boolean mayEditMessageAsModerator() {
return isAdm;
}
@Override
public boolean mayDeleteMessageAsModerator() {
return isAdm;
}
@Override
public boolean mayArchiveForum() {
return !isGuest;
}
@Override
public boolean mayFilterForUser() {
return isAdm;
}
@Override
public SubscriptionContext getSubscriptionContext() {
return subsContext;
}
}, titleInfo);
return forumController;
}
Aggregations