use of org.olat.modules.fo.ui.events.DeleteMessageEvent in project OpenOLAT by OpenOLAT.
the class MessageListController method doDeleteMessage.
private void doDeleteMessage(UserRequest ureq, MessageView message) {
boolean userIsMsgCreator = message.isAuthor();
if (foCallback.mayDeleteMessageAsModerator() || (userIsMsgCreator && forumManager.countMessageChildren(message.getKey()) == 0)) {
Message reloadedMessage = forumManager.getMessageById(message.getKey());
if (reloadedMessage != null) {
// this delete the topic / thread
if (reloadedMessage.getParent() == null) {
forumManager.deleteMessageTree(forum.getKey(), reloadedMessage);
// delete topics
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_DELETE, getClass(), LoggingResourceable.wrap(reloadedMessage));
// back to thread list
fireEvent(ureq, new DeleteThreadEvent());
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.DELETED_THREAD, reloadedMessage.getKey(), reloadedMessage.getKey(), getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forum);
} else {
Message threadTop = reloadedMessage.getThreadtop();
forumManager.deleteMessageTree(forum.getKey(), reloadedMessage);
threadTop = forumManager.updateMessage(threadTop, true);
if (thread != null) {
// update with the fresh version
thread = threadTop;
}
showInfo("deleteok");
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_MESSAGE_DELETE, getClass(), LoggingResourceable.wrap(reloadedMessage));
// reload
reloadModelAfterDelete(ureq, message);
fireEvent(ureq, new DeleteMessageEvent());
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.DELETED_MESSAGE, threadTop.getKey(), message.getKey(), getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forum);
}
}
} else {
showWarning("may.not.delete.msg.as.author");
}
}
use of org.olat.modules.fo.ui.events.DeleteMessageEvent in project OpenOLAT by OpenOLAT.
the class ForumController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (threadListCtrl == source) {
if (event instanceof SelectMessageEvent) {
doProcessSelectEvent(ureq, (SelectMessageEvent) event);
} else if (event instanceof SelectUserListEvent) {
doUserList(ureq);
}
} else if (viewCtrl == source) {
if (event == Event.BACK_EVENT) {
reloadThreadList |= viewCtrl.hasMarkedNewMessages();
doThreadList(ureq);
} else if (event instanceof DeleteThreadEvent) {
reloadThreadList = true;
doThreadList(ureq);
} else if (event instanceof DeleteMessageEvent) {
reloadThreadList = true;
} else if (event instanceof SelectMessageEvent) {
doProcessSelectEvent(ureq, (SelectMessageEvent) event);
}
} else if (userViewCtrl == source) {
if (event == Event.BACK_EVENT) {
reloadThreadList |= userViewCtrl.hasMarkedNewMessages();
cleanUpMessageViews();
doUserList(ureq);
} else if (event instanceof SelectMessageEvent) {
doProcessSelectEvent(ureq, (SelectMessageEvent) event);
}
} else if (userListCtrl == source) {
if (event == Event.BACK_EVENT) {
removeAsListenerAndDispose(userListCtrl);
userListCtrl = null;
doThreadList(ureq);
} else if (event instanceof SelectUserEvent) {
SelectUserEvent sue = (SelectUserEvent) event;
if (sue.isGuest()) {
doGuestMessageList(ureq);
} else if (StringHelper.containsNonWhitespace(sue.getPseudonym())) {
doPseudonymMessageList(ureq, sue.getIdentityKey(), sue.getPseudonym());
} else if (sue.getIdentityKey() != null) {
doUserMessageList(ureq, sue.getIdentityKey());
}
}
}
}
use of org.olat.modules.fo.ui.events.DeleteMessageEvent in project openolat by klemens.
the class MessageListController method doDeleteMessage.
private void doDeleteMessage(UserRequest ureq, MessageView message) {
boolean userIsMsgCreator = message.isAuthor();
if (foCallback.mayDeleteMessageAsModerator() || (userIsMsgCreator && forumManager.countMessageChildren(message.getKey()) == 0)) {
Message reloadedMessage = forumManager.getMessageById(message.getKey());
if (reloadedMessage != null) {
// this delete the topic / thread
if (reloadedMessage.getParent() == null) {
forumManager.deleteMessageTree(forum.getKey(), reloadedMessage);
// delete topics
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_DELETE, getClass(), LoggingResourceable.wrap(reloadedMessage));
// back to thread list
fireEvent(ureq, new DeleteThreadEvent());
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.DELETED_THREAD, reloadedMessage.getKey(), reloadedMessage.getKey(), getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forum);
} else {
Message threadTop = reloadedMessage.getThreadtop();
forumManager.deleteMessageTree(forum.getKey(), reloadedMessage);
threadTop = forumManager.updateMessage(threadTop, true);
if (thread != null) {
// update with the fresh version
thread = threadTop;
}
showInfo("deleteok");
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_MESSAGE_DELETE, getClass(), LoggingResourceable.wrap(reloadedMessage));
// reload
reloadModelAfterDelete(ureq, message);
fireEvent(ureq, new DeleteMessageEvent());
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.DELETED_MESSAGE, threadTop.getKey(), message.getKey(), getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forum);
}
}
} else {
showWarning("may.not.delete.msg.as.author");
}
}
use of org.olat.modules.fo.ui.events.DeleteMessageEvent in project openolat by klemens.
the class ForumController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (threadListCtrl == source) {
if (event instanceof SelectMessageEvent) {
doProcessSelectEvent(ureq, (SelectMessageEvent) event);
} else if (event instanceof SelectUserListEvent) {
doUserList(ureq);
}
} else if (viewCtrl == source) {
if (event == Event.BACK_EVENT) {
reloadThreadList |= viewCtrl.hasMarkedNewMessages();
doThreadList(ureq);
} else if (event instanceof DeleteThreadEvent) {
reloadThreadList = true;
doThreadList(ureq);
} else if (event instanceof DeleteMessageEvent) {
reloadThreadList = true;
} else if (event instanceof SelectMessageEvent) {
doProcessSelectEvent(ureq, (SelectMessageEvent) event);
}
} else if (userViewCtrl == source) {
if (event == Event.BACK_EVENT) {
reloadThreadList |= userViewCtrl.hasMarkedNewMessages();
cleanUpMessageViews();
doUserList(ureq);
} else if (event instanceof SelectMessageEvent) {
doProcessSelectEvent(ureq, (SelectMessageEvent) event);
}
} else if (userListCtrl == source) {
if (event == Event.BACK_EVENT) {
removeAsListenerAndDispose(userListCtrl);
userListCtrl = null;
doThreadList(ureq);
} else if (event instanceof SelectUserEvent) {
SelectUserEvent sue = (SelectUserEvent) event;
if (sue.isGuest()) {
doGuestMessageList(ureq);
} else if (StringHelper.containsNonWhitespace(sue.getPseudonym())) {
doPseudonymMessageList(ureq, sue.getIdentityKey(), sue.getPseudonym());
} else if (sue.getIdentityKey() != null) {
doUserMessageList(ureq, sue.getIdentityKey());
}
}
}
}
Aggregations