use of org.olat.modules.fo.ForumChangedEvent in project OpenOLAT by OpenOLAT.
the class MessageListController method doCloseThread.
/**
* Sets the closed status to the thread message.
* @param ureq
* @param msg
* @param closed
*/
private void doCloseThread() {
if (thread != null) {
thread = forumManager.getMessageById(thread.getKey());
Status status = Status.getStatus(thread.getStatusCode());
status.setClosed(true);
thread.setStatusCode(Status.getStatusCode(status));
thread = forumManager.updateMessage(thread, false);
// before sending async event
DBFactory.getInstance().commit();
closeThreadButton.setVisible(false);
openThreadButton.setVisible(true && !guestOnly);
mainVC.setDirty(true);
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.CLOSE, thread.getKey(), null, getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forumOres);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_CLOSE, getClass(), LoggingResourceable.wrap(thread));
}
}
use of org.olat.modules.fo.ForumChangedEvent in project OpenOLAT by OpenOLAT.
the class MessageListController method doShowThread.
/**
* Sets the hidden status to the threadtop message.
* @param ureq
* @param msg
* @param hidden
*/
private void doShowThread() {
if (thread != null) {
thread = forumManager.getMessageById(thread.getKey());
Status status = Status.getStatus(thread.getStatusCode());
status.setHidden(false);
thread.setStatusCode(Status.getStatusCode(status));
thread = forumManager.updateMessage(thread, true);
// before sending async event
DBFactory.getInstance().commit();
hideThreadButton.setVisible(true && !guestOnly);
showThreadButton.setVisible(false);
mainVC.setDirty(true);
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.SHOW, thread.getKey(), null, getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forumOres);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_SHOW, getClass(), LoggingResourceable.wrap(thread));
}
}
use of org.olat.modules.fo.ForumChangedEvent in project OpenOLAT by OpenOLAT.
the class MessageListController method event.
@Override
public void event(Event event) {
if (event instanceof ForumChangedEvent) {
ForumChangedEvent fce = (ForumChangedEvent) event;
if (ForumChangedEvent.CHANGED_MESSAGE.equals(fce.getCommand()) || ForumChangedEvent.NEW_MESSAGE.equals(fce.getCommand()) || ForumChangedEvent.DELETED_MESSAGE.equals(fce.getCommand())) {
Long threadtopKey = fce.getThreadtopKey();
Long senderId = fce.getSendByIdentityKey();
if (thread != null && threadtopKey != null && thread.getKey().equals(threadtopKey) && (senderId == null || !senderId.equals(getIdentity().getKey()))) {
reloadList = true;
}
}
}
}
use of org.olat.modules.fo.ForumChangedEvent in project OpenOLAT by OpenOLAT.
the class MessageListController method doToogleSticky.
private void doToogleSticky() {
Status status = Status.getStatus(thread.getStatusCode());
status.setSticky(!status.isSticky());
thread.setStatusCode(Status.getStatusCode(status));
thread = forumManager.updateMessage(thread, false);
DBFactory.getInstance().commit();
stickyButton.setVisible(!status.isSticky() && foCallback.mayEditMessageAsModerator());
removeStickyButton.setVisible(status.isSticky() && foCallback.mayEditMessageAsModerator());
mainVC.setDirty(true);
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.STICKY, thread.getKey(), null, getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forumOres);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_MESSAGE_EDIT, getClass(), LoggingResourceable.wrap(thread));
}
use of org.olat.modules.fo.ForumChangedEvent in project OpenOLAT by OpenOLAT.
the class ForumManager method splitThread.
/**
* Splits the current thread starting from the current message.
* It updates the messages of the selected subthread by setting the Parent and the Threadtop.
* The method send a SPLIT event, and make a commit before sending it.
*
* @param msgid
* @return the top message of the newly created thread.
*/
public Message splitThread(Message msg) {
Message newTopMessage = null;
if (msg.getThreadtop() == null) {
newTopMessage = msg;
} else {
// it only make sense to split a thread if the current message is not a threadtop message.
List<Message> threadList = getThread(msg.getThreadtop().getKey());
List<Message> subthreadList = new ArrayList<>();
getSubthread(msg, threadList, subthreadList);
newTopMessage = getMessageById(msg.getKey());
newTopMessage.setParent(null);
newTopMessage.setThreadtop(null);
newTopMessage = dbInstance.getCurrentEntityManager().merge(newTopMessage);
for (Message message : subthreadList) {
message.setThreadtop(newTopMessage);
message = dbInstance.getCurrentEntityManager().merge(message);
}
// before sending async event
dbInstance.commit();
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.SPLIT, newTopMessage.getKey(), null, null);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, newTopMessage.getForum());
}
return newTopMessage;
}
Aggregations