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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations