use of org.olat.modules.fo.ForumChangedEvent in project OpenOLAT by OpenOLAT.
the class MessageListController method doHideThread.
/**
* Sets the hidden status to the thread message.
* @param ureq
* @param msg
* @param hidden
*/
private void doHideThread() {
if (thread != null) {
thread = forumManager.getMessageById(thread.getKey());
Status status = Status.getStatus(thread.getStatusCode());
status.setHidden(true);
thread.setStatusCode(Status.getStatusCode(status));
thread = forumManager.updateMessage(thread, false);
// before sending async event
DBFactory.getInstance().commit();
hideThreadButton.setVisible(false);
showThreadButton.setVisible(true && !guestOnly);
mainVC.setDirty(true);
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.HIDE, thread.getKey(), null, getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forumOres);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_HIDE, getClass(), LoggingResourceable.wrap(thread));
}
}
use of org.olat.modules.fo.ForumChangedEvent in project OpenOLAT by OpenOLAT.
the class MessageListController method doOpenThread.
private void doOpenThread() {
if (thread != null) {
thread = forumManager.getMessageById(thread.getKey());
Status status = Status.getStatus(thread.getStatusCode());
status.setClosed(false);
thread.setStatusCode(Status.getStatusCode(status));
thread = forumManager.updateMessage(thread, true);
// before sending async event
DBFactory.getInstance().commit();
closeThreadButton.setVisible(true && !guestOnly);
openThreadButton.setVisible(false);
mainVC.setDirty(true);
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.OPEN, thread.getKey(), null, getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forumOres);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_REOPEN, getClass(), LoggingResourceable.wrap(thread));
}
}
use of org.olat.modules.fo.ForumChangedEvent 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.ForumChangedEvent in project openolat by klemens.
the class MessageEditController method commitMessage.
private void commitMessage(UserRequest ureq) {
// if msg exist -> persist uploads directly to final dest
if (message.getKey() != null) {
message = fm.loadMessage(message.getKey());
}
// set values from form to message
message.setTitle(titleEl.getValue());
String body = bodyEl.getValue();
body = body.replace("<p> ", "<p>");
message.setBody(body.trim());
if (usePseudonymEl != null && (usePseudonymEl.isAtLeastSelected(1) || guestOnly)) {
String password = passwordEl.getValue();
String pseudonym = pseudonymEl.getValue();
if (StringHelper.containsNonWhitespace(password)) {
List<Pseudonym> protectedPseudonyms = fm.getPseudonyms(pseudonym);
if (protectedPseudonyms.isEmpty()) {
fm.createProtectedPseudonym(pseudonym, password);
ureq.getUserSession().putEntry("FOPseudo-" + pseudonym, password);
} else {
// we double check the password
boolean authenticated = false;
for (Pseudonym protectedPseudonym : protectedPseudonyms) {
if (fm.authenticatePseudonym(protectedPseudonym, password)) {
ureq.getUserSession().putEntry("FOPseudo-" + protectedPseudonym.getPseudonym(), password);
authenticated = true;
break;
}
}
if (!authenticated) {
validateFormLogic(ureq);
return;
}
}
}
message.setPseudonym(pseudonym);
if (guestOnly) {
ureq.getUserSession().putEntry("FOPseudo" + forum.getKey(), message.getPseudonym());
}
} else if (message.getCreator() != null && message.getCreator().equals(getIdentity())) {
message.setPseudonym(null);
}
if (editMode == EditMode.newThread) {
if (foCallback.mayOpenNewThread()) {
// save a new thread
fm.addTopMessage(message);
fm.markNewMessageAsRead(getIdentity(), forum, message);
persistTempUploadedFiles(message);
// if notification is enabled -> notify the publisher about news
notifiySubscription();
addLoggingResourceable(LoggingResourceable.wrap(message));
// commit before sending events
DBFactory.getInstance().commit();
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.NEW_MESSAGE, message.getKey(), message.getKey(), getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forum);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_MESSAGE_CREATE, getClass());
} else {
showWarning("may.not.save.msg.as.author");
}
} else if (editMode == EditMode.edit) {
boolean children = fm.countMessageChildren(message.getKey()) > 0;
if (foCallback.mayEditMessageAsModerator() || (userIsMsgCreator && !children)) {
message.setModifier(getIdentity());
message = fm.updateMessage(message, true);
persistTempUploadedFiles(message);
notifiySubscription();
// commit before sending events
DBFactory.getInstance().commit();
Long threadTopKey = message.getThreadtop() == null ? null : message.getThreadtop().getKey();
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.CHANGED_MESSAGE, threadTopKey, message.getKey(), getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forum);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_MESSAGE_EDIT, getClass(), LoggingResourceable.wrap(message));
} else {
showWarning("may.not.save.msg.as.author");
}
} else if (editMode == EditMode.reply) {
fm.replyToMessage(message, parentMessage);
fm.markNewMessageAsRead(getIdentity(), forum, message);
persistTempUploadedFiles(message);
notifiySubscription();
Long threadTopKey = message.getThreadtop() == null ? null : message.getThreadtop().getKey();
// commit before sending events
DBFactory.getInstance().commit();
ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.NEW_MESSAGE, threadTopKey, message.getKey(), getIdentity());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forum);
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_REPLY_MESSAGE_CREATE, getClass(), LoggingResourceable.wrap(message));
}
}
use of org.olat.modules.fo.ForumChangedEvent in project openolat by klemens.
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));
}
}
Aggregations