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