Search in sources :

Example 61 with Forum

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

the class WikiMainController method selectTab.

private void selectTab(UserRequest ureq, String command, String compName, WikiPage page, Wiki wiki) {
    // first release a potential lock on this page. only when the edit tab
    // is acitve
    // a lock will be created. in all other cases it is save to release an
    // existing lock
    doReleaseEditLock();
    if (command.equals(TabbedPaneChangedEvent.TAB_CHANGED)) {
        updatePageContext(ureq, page);
    }
    if (command.equals(TabbedPaneChangedEvent.TAB_CHANGED) && compName.equals("vc_article")) {
    /**
     *********************************************************************
     * tabbed pane change to article
     *********************************************************************
     */
    // if(page.getContent().equals(""))
    // wikiArticleComp.setVisible(false);
    // FIXME:guido: ... && comp == articleContent)) etc.
    } else if (command.equals(TabbedPaneChangedEvent.TAB_CHANGED) && compName.equals("vc_edit")) {
        /**
         *********************************************************************
         * tabbed pane change to edit tab
         *********************************************************************
         */
        wikiEditForm.resetUpdateComment();
        updateFileAndLinkList(wiki);
        // try to edit acquire lock for this page
        tryToSetEditLock(page, ureq, ores);
    } else if (command.equals(TabbedPaneChangedEvent.TAB_CHANGED) && compName.equals("vc_versions")) {
        /**
         *********************************************************************
         * tabbed pane change to versioning tab
         *********************************************************************
         */
        versioningTableModel = new HistoryTableDateModel(wiki.getHistory(page), getTranslator());
        removeAsListenerAndDispose(versioningTableCtr);
        versioningTableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
        listenTo(versioningTableCtr);
        versioningTableModel.addColumnDescriptors(versioningTableCtr);
        versioningTableCtr.setTableDataModel(versioningTableModel);
        versioningTableCtr.modelChanged();
        versioningTableCtr.setSortColumn(1, false);
        versioningContent.put("versions", versioningTableCtr.getInitialComponent());
        versioningContent.contextPut("diffs", diffs);
    } else if (command.equals(TabbedPaneChangedEvent.TAB_CHANGED) && compName.equals("vc_discuss")) {
        /**
         *********************************************************************
         * tabbed pane change to discussion tab
         *********************************************************************
         */
        Forum forum = null;
        if (page.getForumKey() > 0) {
            forum = ForumManager.getInstance().loadForum(Long.valueOf(page.getForumKey()));
        }
        if (forum == null) {
            forum = ForumManager.getInstance().addAForum();
            page.setForumKey(forum.getKey().longValue());
            WikiManager.getInstance().updateWikiPageProperties(ores, page);
        }
        ForumCallback forumCallback = securityCallback.getForumCallback();
        ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(forum);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, getWindowControl());
        removeAsListenerAndDispose(forumController);
        forumController = new ForumController(ureq, bwControl, forum, forumCallback, false);
        listenTo(forumController);
        discussionContent.put("articleforum", forumController.getInitialComponent());
    }
    OLATResourceable pageRes = OresHelper.createOLATResourceableTypeWithoutCheck("path=" + page.getPageName());
    WindowControl wc = addToHistory(ureq, pageRes, null);
    OLATResourceable tabOres = tabs.getTabResource();
    addToHistory(ureq, tabOres, null, wc, true);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) TableController(org.olat.core.gui.components.table.TableController) ForumCallback(org.olat.modules.fo.ForumCallback) HistoryTableDateModel(org.olat.modules.wiki.versioning.HistoryTableDateModel) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) ForumController(org.olat.modules.fo.ui.ForumController) Forum(org.olat.modules.fo.Forum)

Example 62 with Forum

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

the class DialogElementsManagerTest method getDialogElementByForumKey.

@Test
public void getDialogElementByForumKey() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("session-1");
    String subIdent = UUID.randomUUID().toString();
    DialogElement element = dialogElementsManager.createDialogElement(entry, author, "task_e.txt", 235l, subIdent);
    dbInstance.commitAndCloseSession();
    Forum forum = element.getForum();
    DialogElement loadedElement = dialogElementsManager.getDialogElementByForum(forum.getKey());
    Assert.assertNotNull(loadedElement.getKey());
    Assert.assertEquals(forum, loadedElement.getForum());
    Assert.assertEquals(author, loadedElement.getAuthor());
    Assert.assertEquals("task_e.txt", loadedElement.getFilename());
    Assert.assertEquals(Long.valueOf(235l), loadedElement.getSize());
    Assert.assertEquals(subIdent, loadedElement.getSubIdent());
    Assert.assertEquals(entry, loadedElement.getEntry());
}
Also used : DialogElement(org.olat.course.nodes.dialog.DialogElement) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Forum(org.olat.modules.fo.Forum) Test(org.junit.Test)

Example 63 with Forum

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

the class LearningGroupWebService method getForum.

/**
 * Return the Forum web service
 * @param groupKey The key of the group
 * @param request The HTTP Request
 * @return
 */
@Path("{groupKey}/forum")
public ForumWebService getForum(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(groupKey);
    if (bg == null) {
        return null;
    }
    if (!isGroupManager(request)) {
        Identity identity = RestSecurityHelper.getIdentity(request);
        if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
            return null;
        }
    }
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_FORUM)) {
        Forum forum = collabTools.getForum();
        return new ForumWebService(forum);
    }
    return null;
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) ForumWebService(org.olat.modules.fo.restapi.ForumWebService) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) Forum(org.olat.modules.fo.Forum) Path(javax.ws.rs.Path)

Example 64 with Forum

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

the class ForumNodeForumCallback method createNodeRunConstructionResult.

/**
 * @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(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 NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, final UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Roles roles = ureq.getUserSession().getRoles();
    Forum theForum = loadOrCreateForum(userCourseEnv.getCourseEnvironment());
    boolean isOlatAdmin = roles.isOLATAdmin();
    boolean isGuestOnly = roles.isGuestOnly();
    // Add message id to business path if nodemcd is available
    if (nodecmd != null) {
        try {
            Long messageId = Long.valueOf(nodecmd);
            BusinessControlFactory bcf = BusinessControlFactory.getInstance();
            BusinessControl businessControl = bcf.createFromString("[Message:" + messageId + "]");
            wControl = bcf.createBusinessWindowControl(businessControl, wControl);
        } catch (NumberFormatException e) {
            // ups, nodecmd is not a message, what the heck is it then?
            log.warn("Could not create message ID from given nodemcd::" + nodecmd, e);
        }
    }
    // for guests, check if posting is allowed
    boolean pseudonymPostAllowed = false;
    boolean defaultPseudonym = false;
    boolean guestPostAllowed = false;
    if (roles.isGuestOnly()) {
        String config = getModuleConfiguration().getStringValue(FOCourseNodeEditController.GUEST_POST_ALLOWED);
        guestPostAllowed = "true".equals(config);
    } else {
        ForumModule forumModule = CoreSpringFactory.getImpl(ForumModule.class);
        String config = getModuleConfiguration().getStringValue(FOCourseNodeEditController.PSEUDONYM_POST_ALLOWED);
        pseudonymPostAllowed = forumModule.isAnonymousPostingWithPseudonymEnabled() && "true".equals(config);
        if (pseudonymPostAllowed) {
            defaultPseudonym = getModuleConfiguration().getBooleanSafe(FOCourseNodeEditController.PSEUDONYM_POST_DEFAULT, forumModule.isPseudonymForMessageEnabledByDefault());
        }
    }
    // Create subscription context and run controller
    SubscriptionContext forumSubContext = CourseModule.createSubscriptionContext(userCourseEnv.getCourseEnvironment(), this);
    ForumCallback foCallback = userCourseEnv.isCourseReadOnly() ? new ReadOnlyForumCallback(ne, isOlatAdmin, isGuestOnly) : new ForumNodeForumCallback(ne, isOlatAdmin, isGuestOnly, guestPostAllowed, pseudonymPostAllowed, defaultPseudonym, forumSubContext);
    FOCourseNodeRunController forumC = new FOCourseNodeRunController(ureq, wControl, theForum, foCallback, this);
    return new NodeRunConstructionResult(forumC);
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) Roles(org.olat.core.id.Roles) FOCourseNodeRunController(org.olat.course.nodes.fo.FOCourseNodeRunController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) Forum(org.olat.modules.fo.Forum) ForumModule(org.olat.modules.fo.ForumModule) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) ForumCallback(org.olat.modules.fo.ForumCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Example 65 with Forum

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

the class ForumNodeForumCallback method saveMultiForums.

private Forum saveMultiForums(final CourseEnvironment courseEnv) {
    final ForumManager fom = CoreSpringFactory.getImpl(ForumManager.class);
    final OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(FOCourseNode.class, new Long(getIdent()));
    return CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerCallback<Forum>() {

        @Override
        public Forum execute() {
            List<Property> forumKeyProps = courseEnv.getCoursePropertyManager().findCourseNodeProperties(FOCourseNode.this, null, null, FORUM_KEY);
            Forum masterForum;
            if (forumKeyProps.size() == 1) {
                masterForum = loadForum(courseEnv, forumKeyProps.get(0));
            } else if (forumKeyProps.size() > 1) {
                Long masterForumKey = forumKeyProps.get(0).getLongValue();
                List<Long> forumsToMerge = new ArrayList<>();
                for (int i = 1; i < forumKeyProps.size(); i++) {
                    forumsToMerge.add(forumKeyProps.get(i).getLongValue());
                }
                fom.mergeForums(masterForumKey, forumsToMerge);
                masterForum = fom.loadForum(masterForumKey);
                for (int i = 1; i < forumKeyProps.size(); i++) {
                    courseEnv.getCoursePropertyManager().deleteProperty(forumKeyProps.get(i));
                }
            } else {
                masterForum = null;
            }
            return masterForum;
        }
    });
}
Also used : ForumManager(org.olat.modules.fo.manager.ForumManager) OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) List(java.util.List) 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