Search in sources :

Example 1 with ForumCallback

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

the class CollaborationTools method createForumController.

/**
 * @param ureq
 * @param wControl
 * @param isAdmin
 * @param subsContext the subscriptioncontext if subscriptions to this forum
 *          should be possible
 * @return a forum controller
 */
public Controller createForumController(UserRequest ureq, WindowControl wControl, boolean isAdmin, boolean isGuestOnly, final SubscriptionContext subsContext) {
    final boolean isAdm = isAdmin;
    final boolean isGuest = isGuestOnly;
    Forum forum = getForum();
    Translator trans = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
    TitleInfo titleInfo = new TitleInfo(null, trans.translate("collabtools.named.hasForum"));
    titleInfo.setSeparatorEnabled(true);
    Controller forumController = ForumUIFactory.getTitledForumController(ureq, wControl, forum, new ForumCallback() {

        @Override
        public boolean mayUsePseudonym() {
            return false;
        }

        @Override
        public boolean mayOpenNewThread() {
            return true;
        }

        @Override
        public boolean mayReplyMessage() {
            return true;
        }

        @Override
        public boolean mayEditOwnMessage() {
            return true;
        }

        @Override
        public boolean mayDeleteOwnMessage() {
            return true;
        }

        @Override
        public boolean mayEditMessageAsModerator() {
            return isAdm;
        }

        @Override
        public boolean mayDeleteMessageAsModerator() {
            return isAdm;
        }

        @Override
        public boolean mayArchiveForum() {
            return !isGuest;
        }

        @Override
        public boolean mayFilterForUser() {
            return isAdm;
        }

        @Override
        public SubscriptionContext getSubscriptionContext() {
            return subsContext;
        }
    }, titleInfo);
    return forumController;
}
Also used : Translator(org.olat.core.gui.translator.Translator) TitleInfo(org.olat.core.gui.control.generic.title.TitleInfo) ForumCallback(org.olat.modules.fo.ForumCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) ChatToolController(org.olat.instantMessaging.ui.ChatToolController) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) BinderController(org.olat.modules.portfolio.ui.BinderController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ContactFormController(org.olat.modules.co.ContactFormController) Controller(org.olat.core.gui.control.Controller) CalendarController(org.olat.commons.calendar.ui.CalendarController) InfoGroupRunController(org.olat.group.ui.run.InfoGroupRunController) Forum(org.olat.modules.fo.Forum)

Example 2 with ForumCallback

use of org.olat.modules.fo.ForumCallback in project OpenOLAT by OpenOLAT.

the class CollaborationTools method createForumController.

/**
 * @param ureq
 * @param wControl
 * @param isAdmin
 * @param subsContext the subscriptioncontext if subscriptions to this forum
 *          should be possible
 * @return a forum controller
 */
public Controller createForumController(UserRequest ureq, WindowControl wControl, boolean isAdmin, boolean isGuestOnly, final SubscriptionContext subsContext) {
    final boolean isAdm = isAdmin;
    final boolean isGuest = isGuestOnly;
    Forum forum = getForum();
    Translator trans = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
    TitleInfo titleInfo = new TitleInfo(null, trans.translate("collabtools.named.hasForum"));
    titleInfo.setSeparatorEnabled(true);
    Controller forumController = ForumUIFactory.getTitledForumController(ureq, wControl, forum, new ForumCallback() {

        @Override
        public boolean mayUsePseudonym() {
            return false;
        }

        @Override
        public boolean mayOpenNewThread() {
            return true;
        }

        @Override
        public boolean mayReplyMessage() {
            return true;
        }

        @Override
        public boolean mayEditOwnMessage() {
            return true;
        }

        @Override
        public boolean mayDeleteOwnMessage() {
            return true;
        }

        @Override
        public boolean mayEditMessageAsModerator() {
            return isAdm;
        }

        @Override
        public boolean mayDeleteMessageAsModerator() {
            return isAdm;
        }

        @Override
        public boolean mayArchiveForum() {
            return !isGuest;
        }

        @Override
        public boolean mayFilterForUser() {
            return isAdm;
        }

        @Override
        public SubscriptionContext getSubscriptionContext() {
            return subsContext;
        }
    }, titleInfo);
    return forumController;
}
Also used : Translator(org.olat.core.gui.translator.Translator) TitleInfo(org.olat.core.gui.control.generic.title.TitleInfo) ForumCallback(org.olat.modules.fo.ForumCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) ChatToolController(org.olat.instantMessaging.ui.ChatToolController) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) BinderController(org.olat.modules.portfolio.ui.BinderController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ContactFormController(org.olat.modules.co.ContactFormController) Controller(org.olat.core.gui.control.Controller) CalendarController(org.olat.commons.calendar.ui.CalendarController) InfoGroupRunController(org.olat.group.ui.run.InfoGroupRunController) Forum(org.olat.modules.fo.Forum)

Example 3 with ForumCallback

use of org.olat.modules.fo.ForumCallback in project OpenOLAT by OpenOLAT.

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 4 with ForumCallback

use of org.olat.modules.fo.ForumCallback in project OpenOLAT by OpenOLAT.

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 5 with ForumCallback

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

Aggregations

Forum (org.olat.modules.fo.Forum)6 ForumCallback (org.olat.modules.fo.ForumCallback)6 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)4 CalendarController (org.olat.commons.calendar.ui.CalendarController)2 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)2 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)2 TableController (org.olat.core.gui.components.table.TableController)2 Controller (org.olat.core.gui.control.Controller)2 WindowControl (org.olat.core.gui.control.WindowControl)2 TitleInfo (org.olat.core.gui.control.generic.title.TitleInfo)2 Translator (org.olat.core.gui.translator.Translator)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 Roles (org.olat.core.id.Roles)2 BusinessControl (org.olat.core.id.context.BusinessControl)2 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 FOCourseNodeRunController (org.olat.course.nodes.fo.FOCourseNodeRunController)2 CourseLinkProviderController (org.olat.course.run.calendar.CourseLinkProviderController)2 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)2 InfoGroupRunController (org.olat.group.ui.run.InfoGroupRunController)2