Search in sources :

Example 1 with ForumManager

use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.

the class FOCourseNodeIndexer method doIndexForum.

/**
 * Index a forum in a course.
 * @param parentResourceContext
 * @param course
 * @param courseNode
 * @param indexWriter
 * @throws IOException
 */
private void doIndexForum(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (log.isDebug())
        log.debug("Index Course Forum...");
    ForumManager fom = ForumManager.getInstance();
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    Property forumKeyProperty = cpm.findCourseNodeProperty(courseNode, null, null, FOCourseNode.FORUM_KEY);
    // Check if forum-property exist
    if (forumKeyProperty != null) {
        Long forumKey = forumKeyProperty.getLongValue();
        Forum forum = fom.loadForum(forumKey);
        parentResourceContext.setDocumentType(TYPE);
        doIndexAllMessages(parentResourceContext, forum, indexWriter);
    }
}
Also used : ForumManager(org.olat.modules.fo.manager.ForumManager) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) Forum(org.olat.modules.fo.Forum)

Example 2 with ForumManager

use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.

the class NotificationsTest method createMessage.

private Message createMessage(Identity id, Forum fo) {
    ForumManager fm = ForumManager.getInstance();
    Message m1 = fm.createMessage(fo, id, false);
    m1.setTitle("Thread-1");
    m1.setBody("Body of Thread-1");
    fm.addTopMessage(m1);
    return m1;
}
Also used : Message(org.olat.modules.fo.Message) ForumManager(org.olat.modules.fo.manager.ForumManager)

Example 3 with ForumManager

use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.

the class ForumArtefactHandler method prefillArtefactAccordingToSource.

/**
 * @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
 */
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
    super.prefillArtefactAccordingToSource(artefact, source);
    if (source instanceof OLATResourceable) {
        OLATResourceable ores = (OLATResourceable) source;
        ForumManager fMgr = ForumManager.getInstance();
        Message fm = fMgr.loadMessage(ores.getResourceableId());
        String thread = fm.getThreadtop() != null ? fm.getThreadtop().getTitle() + " - " : "";
        artefact.setTitle(thread + fm.getTitle());
        VFSContainer msgContainer = fMgr.getMessageContainer(fm.getForum().getKey(), fm.getKey());
        if (msgContainer != null) {
            List<VFSItem> foAttach = msgContainer.getItems();
            if (foAttach.size() != 0) {
                artefact.setFileSourceContainer(msgContainer);
            }
        }
        artefact.setSignature(70);
        artefact.setFulltextContent(fm.getBody());
    }
}
Also used : Message(org.olat.modules.fo.Message) OLATResourceable(org.olat.core.id.OLATResourceable) ForumManager(org.olat.modules.fo.manager.ForumManager) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 4 with ForumManager

use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.

the class ForumImportWebService method getForumWebservice.

/**
 * Web service to manage a forum
 * @param forumKey The key of the forum
 * @return
 */
@Path("{forumKey}")
public ForumWebService getForumWebservice(@PathParam("forumKey") Long forumKey) {
    ForumManager fom = ForumManager.getInstance();
    Forum forum = fom.loadForum(forumKey);
    return new ForumWebService(forum);
}
Also used : ForumManager(org.olat.modules.fo.manager.ForumManager) Forum(org.olat.modules.fo.Forum) Path(javax.ws.rs.Path)

Example 5 with ForumManager

use of org.olat.modules.fo.manager.ForumManager 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)

Aggregations

ForumManager (org.olat.modules.fo.manager.ForumManager)38 Forum (org.olat.modules.fo.Forum)20 Property (org.olat.properties.Property)14 URI (java.net.URI)12 HttpResponse (org.apache.http.HttpResponse)12 HttpPut (org.apache.http.client.methods.HttpPut)12 Test (org.junit.Test)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 Message (org.olat.modules.fo.Message)12 MessageVO (org.olat.modules.fo.restapi.MessageVO)12 VFSItem (org.olat.core.util.vfs.VFSItem)10 BufferedImage (java.awt.image.BufferedImage)8 InputStream (java.io.InputStream)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)8 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)8 AssertException (org.olat.core.logging.AssertException)6 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)6 File (java.io.File)4 ArrayList (java.util.ArrayList)4