Search in sources :

Example 26 with Message

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;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) Message(org.olat.modules.fo.Message) FOCourseNode(org.olat.course.nodes.FOCourseNode) ICourse(org.olat.course.ICourse) Forum(org.olat.modules.fo.Forum)

Example 27 with Message

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;
}
Also used : Message(org.olat.modules.fo.Message) ForumManager(org.olat.modules.fo.manager.ForumManager) ArrayList(java.util.ArrayList) Forum(org.olat.modules.fo.Forum)

Example 28 with Message

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;
}
Also used : Message(org.olat.modules.fo.Message)

Example 29 with Message

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);
}
Also used : Message(org.olat.modules.fo.Message)

Example 30 with Message

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);
    }
}
Also used : Message(org.olat.modules.fo.Message) ForumThread(org.olat.modules.fo.model.ForumThread) SortKey(org.olat.core.commons.persistence.SortKey) Date(java.util.Date)

Aggregations

Message (org.olat.modules.fo.Message)108 Identity (org.olat.core.id.Identity)18 OLATResourceable (org.olat.core.id.OLATResourceable)16 ErrorEditMessage (org.olat.modules.fo.ui.events.ErrorEditMessage)16 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)12 Date (java.util.Date)8 HttpResponse (org.apache.http.HttpResponse)8 Test (org.junit.Test)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 ICourse (org.olat.course.ICourse)8 FOCourseNode (org.olat.course.nodes.FOCourseNode)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 PublisherData (org.olat.core.commons.services.notifications.PublisherData)5