Search in sources :

Example 1 with DeleteMessageEvent

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");
    }
}
Also used : ForumChangedEvent(org.olat.modules.fo.ForumChangedEvent) DeleteThreadEvent(org.olat.modules.fo.ui.events.DeleteThreadEvent) ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) DeleteMessageEvent(org.olat.modules.fo.ui.events.DeleteMessageEvent)

Example 2 with DeleteMessageEvent

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());
            }
        }
    }
}
Also used : SelectUserListEvent(org.olat.modules.fo.ui.events.SelectUserListEvent) DeleteThreadEvent(org.olat.modules.fo.ui.events.DeleteThreadEvent) SelectUserEvent(org.olat.modules.fo.ui.events.SelectUserEvent) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent) DeleteMessageEvent(org.olat.modules.fo.ui.events.DeleteMessageEvent)

Example 3 with DeleteMessageEvent

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");
    }
}
Also used : ForumChangedEvent(org.olat.modules.fo.ForumChangedEvent) DeleteThreadEvent(org.olat.modules.fo.ui.events.DeleteThreadEvent) ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) DeleteMessageEvent(org.olat.modules.fo.ui.events.DeleteMessageEvent)

Example 4 with DeleteMessageEvent

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());
            }
        }
    }
}
Also used : SelectUserListEvent(org.olat.modules.fo.ui.events.SelectUserListEvent) DeleteThreadEvent(org.olat.modules.fo.ui.events.DeleteThreadEvent) SelectUserEvent(org.olat.modules.fo.ui.events.SelectUserEvent) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent) DeleteMessageEvent(org.olat.modules.fo.ui.events.DeleteMessageEvent)

Aggregations

DeleteMessageEvent (org.olat.modules.fo.ui.events.DeleteMessageEvent)4 DeleteThreadEvent (org.olat.modules.fo.ui.events.DeleteThreadEvent)4 ForumChangedEvent (org.olat.modules.fo.ForumChangedEvent)2 Message (org.olat.modules.fo.Message)2 ErrorEditMessage (org.olat.modules.fo.ui.events.ErrorEditMessage)2 SelectMessageEvent (org.olat.modules.fo.ui.events.SelectMessageEvent)2 SelectUserEvent (org.olat.modules.fo.ui.events.SelectUserEvent)2 SelectUserListEvent (org.olat.modules.fo.ui.events.SelectUserListEvent)2