use of org.olat.modules.fo.Message in project OpenOLAT by OpenOLAT.
the class FinishCallback method execute.
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
FOCourseNode node = (FOCourseNode) runContext.get(SendMailStepForm.FORUM);
ICourse course = (ICourse) runContext.get(SendMailStepForm.ICOURSE);
CourseEnvironment courseEnv = course.getCourseEnvironment();
Forum chosenforum = node.loadOrCreateForum(courseEnv);
Message msg = (Message) runContext.get(SendMailStepForm.MESSAGE_TO_MOVE);
msg = forumManager.getMessageById(msg.getKey());
Message parentMessage = (Message) runContext.get(SendMailStepForm.PARENT_MESSAGE);
if (parentMessage != null) {
parentMessage = forumManager.getMessageById(parentMessage.getKey());
}
if (msg.getParentKey() == null && msg.getThreadtop() == null) {
msg = forumManager.createOrAppendThreadInAnotherForum(msg, chosenforum, parentMessage);
} else {
msg = forumManager.moveMessageToAnotherForum(msg, chosenforum, parentMessage);
}
// commit before sending event
DBFactory.getInstance().commit();
if ((Boolean) runContext.get(SendMailStepForm.SENDMAIL)) {
sendMail(ureq, wControl, runContext);
}
return StepsMainRunController.DONE_MODIFIED;
}
use of org.olat.modules.fo.Message in project OpenOLAT by OpenOLAT.
the class ForumArchiveManager method convertToThreadTrees.
/**
* If the forumCallback is null no filtering is executed,
* else if a thread is hidden and the user doesn't have moderator rights the
* hidden thread is not included into the archive.
* @param forumId
* @param metaInfo
* @return all top message nodes together with their children in a list
*/
private List<MessageNode> convertToThreadTrees(Long forumId, ForumCallback forumCallback) {
List<MessageNode> topNodeList = new ArrayList<>();
ForumManager fm = ForumManager.getInstance();
Forum f = fm.loadForum(forumId);
List<Message> messages = fm.getMessagesByForum(f);
for (Iterator<Message> iterTop = messages.iterator(); iterTop.hasNext(); ) {
Message msg = iterTop.next();
if (msg.getParent() == null) {
iterTop.remove();
MessageNode topNode = new MessageNode(msg);
if (topNode.isHidden() && (forumCallback == null || (forumCallback != null && forumCallback.mayEditMessageAsModerator()))) {
addChildren(messages, topNode);
topNodeList.add(topNode);
} else if (!topNode.isHidden()) {
addChildren(messages, topNode);
topNodeList.add(topNode);
}
}
}
Collections.sort(topNodeList, new MessageNodeComparator());
return topNodeList;
}
use of org.olat.modules.fo.Message in project OpenOLAT by OpenOLAT.
the class ForumArchiveManager method convertToThreadTree.
/**
* @param messageId
* @param metaInfo
* @return the top message node with all its children
*/
private MessageNode convertToThreadTree(Long topMessageId) {
MessageNode topNode = null;
List<Message> messages = ForumManager.getInstance().getThread(topMessageId);
for (Iterator<Message> iterTop = messages.iterator(); iterTop.hasNext(); ) {
Message msg = iterTop.next();
if (msg.getParent() == null) {
iterTop.remove();
topNode = new MessageNode(msg);
addChildren(messages, topNode);
}
}
return topNode;
}
use of org.olat.modules.fo.Message in project OpenOLAT by OpenOLAT.
the class SelectCourseStepForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String[] threadOrComment;
Message messageToMove = (Message) getFromRunContext(SendMailStepForm.MESSAGE_TO_MOVE);
if (messageToMove != null && messageToMove.getThreadtop() == null) {
threadOrComment = new String[] { translate("forum.thread") };
} else {
threadOrComment = new String[] { translate("forum.comment") };
}
String[] theKeys = new String[] { "radio.foreign.course", "radio.same.course" };
String[] theValues = new String[] { translate("radio.foreign.course", threadOrComment), translate("radio.same.course", threadOrComment) };
chooseCourse = uifactory.addRadiosVertical("step.select.course", formLayout, theKeys, theValues);
chooseCourse.addActionListener(FormEvent.ONCLICK);
}
use of org.olat.modules.fo.Message in project OpenOLAT by OpenOLAT.
the class SelectThreadStepForm method displayAsNewThread.
private void displayAsNewThread(UserRequest ureq) {
Message messageToMove = (Message) getFromRunContext(SendMailStepForm.MESSAGE_TO_MOVE);
String creatorFullname = userManager.getUserDisplayName(messageToMove.getCreator());
Date lastModified = messageToMove.getLastModified();
int numOfPosts = forumManager.countMessageChildren(messageToMove.getKey()) + 1;
ForumThread row = new ForumThread(messageToMove, creatorFullname, lastModified, numOfPosts);
List<ForumThread> threads = threadTableModel.getObjects();
if (containsMessage(row)) {
showWarning("thread.already.exits");
} else {
threads.add(row);
addToRunContext(SendMailStepForm.NEW_THREAD, Boolean.TRUE);
threadTableModel.setObjects(threads);
threadTableModel.sort(new SortKey(ThreadListCols.thread.name(), true));
threadTable.reloadData();
threadTable.reset();
// move on to next wizard step directly
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
}
Aggregations