Search in sources :

Example 66 with Forum

use of org.olat.modules.fo.Forum in project openolat by klemens.

the class ForumNodeForumCallback method createPeekViewRunController.

/**
 * @see org.olat.course.nodes.GenericCourseNode#createPeekViewRunController(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl,
 *      org.olat.course.run.userview.UserCourseEnvironment,
 *      org.olat.course.run.userview.NodeEvaluation)
 */
@Override
public Controller createPeekViewRunController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne) {
    if (ne.isAtLeastOneAccessible()) {
        // Create a forum peekview controller that shows the latest two messages
        Forum theForum = loadOrCreateForum(userCourseEnv.getCourseEnvironment());
        RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        Controller peekViewController = new FOPeekviewController(ureq, wControl, courseEntry, theForum, getIdent(), 3);
        return peekViewController;
    } else {
        // use standard peekview
        return super.createPeekViewRunController(ureq, wControl, userCourseEnv, ne);
    }
}
Also used : FOPeekviewController(org.olat.course.nodes.fo.FOPeekviewController) RepositoryEntry(org.olat.repository.RepositoryEntry) FOPreviewController(org.olat.course.nodes.fo.FOPreviewController) FOCourseNodeRunController(org.olat.course.nodes.fo.FOCourseNodeRunController) NodeEditController(org.olat.course.editor.NodeEditController) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) FOCourseNodeEditController(org.olat.course.nodes.fo.FOCourseNodeEditController) FOPeekviewController(org.olat.course.nodes.fo.FOPeekviewController) Controller(org.olat.core.gui.control.Controller) Forum(org.olat.modules.fo.Forum)

Example 67 with Forum

use of org.olat.modules.fo.Forum in project openolat by klemens.

the class ForumNodeForumCallback method loadOrCreateForum.

/**
 * Private helper method to load the forum from the configuration or create on
 * if it does not yet exist
 *
 * @param userCourseEnv
 * @return the loaded forum
 */
public Forum loadOrCreateForum(final CourseEnvironment courseEnv) {
    updateModuleConfigDefaults(false);
    Forum forum = null;
    List<Property> forumKeyProps = courseEnv.getCoursePropertyManager().findCourseNodeProperties(this, null, null, FORUM_KEY);
    if (forumKeyProps == null || forumKeyProps.isEmpty()) {
        forum = createForum(courseEnv);
    } else if (forumKeyProps.size() == 1) {
        forum = loadForum(courseEnv, forumKeyProps.get(0));
    } else if (forumKeyProps.size() > 1) {
        forum = saveMultiForums(courseEnv);
    }
    return forum;
}
Also used : Property(org.olat.properties.Property) Forum(org.olat.modules.fo.Forum)

Example 68 with Forum

use of org.olat.modules.fo.Forum in project openolat by klemens.

the class DialogElementsManagerImpl method getDialogContainer.

@Override
public VFSContainer getDialogContainer(DialogElement element) {
    Forum forum = element.getForum();
    StringBuilder sb = new StringBuilder();
    sb.append("/forum/").append(forum.getKey()).append("/");
    String pathToForumDir = sb.toString();
    return new OlatRootFolderImpl(pathToForumDir, null);
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Forum(org.olat.modules.fo.Forum)

Example 69 with Forum

use of org.olat.modules.fo.Forum in project openolat by klemens.

the class DialogElementsManagerImpl method deleteDialogElement.

@Override
public void deleteDialogElement(DialogElement element) {
    Forum forum = element.getForum();
    DialogElement reloadedElement = dbInstance.getCurrentEntityManager().getReference(DialogElementImpl.class, element.getKey());
    dbInstance.getCurrentEntityManager().remove(reloadedElement);
    forumManager.deleteForum(forum.getKey());
}
Also used : DialogElement(org.olat.course.nodes.dialog.DialogElement) Forum(org.olat.modules.fo.Forum)

Example 70 with Forum

use of org.olat.modules.fo.Forum in project openolat by klemens.

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

Forum (org.olat.modules.fo.Forum)70 Identity (org.olat.core.id.Identity)24 ForumManager (org.olat.modules.fo.manager.ForumManager)20 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)18 RepositoryEntry (org.olat.repository.RepositoryEntry)18 FOCourseNode (org.olat.course.nodes.FOCourseNode)16 Test (org.junit.Test)14 ICourse (org.olat.course.ICourse)14 Message (org.olat.modules.fo.Message)14 Property (org.olat.properties.Property)14 HttpResponse (org.apache.http.HttpResponse)12 CollaborationTools (org.olat.collaboration.CollaborationTools)12 PublisherData (org.olat.core.commons.services.notifications.PublisherData)12 HttpGet (org.apache.http.client.methods.HttpGet)10 BusinessGroup (org.olat.group.BusinessGroup)10 File (java.io.File)8 URL (java.net.URL)8 Path (javax.ws.rs.Path)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 Roles (org.olat.core.id.Roles)8