Search in sources :

Example 1 with PostCommon

use of net.jforum.view.forum.common.PostCommon in project jforum2 by rafaelsteil.

the class ForumAction method show.

/**
	 * Display all topics in a forum
	 */
public void show() {
    int forumId = this.request.getIntParameter("forum_id");
    ForumDAO fm = DataAccessDriver.getInstance().newForumDAO();
    // The user can access this forum?
    Forum forum = ForumRepository.getForum(forumId);
    if (forum == null || !ForumRepository.isCategoryAccessible(forum.getCategoryId())) {
        new ModerationHelper().denied(I18n.getMessage("ForumListing.denied"));
        return;
    }
    int start = ViewCommon.getStartPage();
    List tmpTopics = TopicsCommon.topicsByForum(forumId, start);
    this.setTemplateName(TemplateKeys.FORUMS_SHOW);
    // Moderation
    UserSession userSession = SessionFacade.getUserSession();
    boolean isLogged = SessionFacade.isLogged();
    boolean isModerator = userSession.isModerator(forumId);
    boolean canApproveMessages = (isLogged && isModerator && SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_APPROVE_MESSAGES));
    Map topicsToApprove = new HashMap();
    if (canApproveMessages) {
        ModerationDAO mdao = DataAccessDriver.getInstance().newModerationDAO();
        topicsToApprove = mdao.topicsByForum(forumId);
        this.context.put("postFormatter", new PostCommon());
    }
    this.context.put("topicsToApprove", topicsToApprove);
    this.context.put("attachmentsEnabled", SecurityRepository.canAccess(SecurityConstants.PERM_ATTACHMENTS_ENABLED, Integer.toString(forumId)) || SecurityRepository.canAccess(SecurityConstants.PERM_ATTACHMENTS_DOWNLOAD));
    this.context.put("topics", TopicsCommon.prepareTopics(tmpTopics));
    this.context.put("allCategories", ForumCommon.getAllCategoriesAndForums(false));
    this.context.put("forum", forum);
    this.context.put("rssEnabled", SystemGlobals.getBoolValue(ConfigKeys.RSS_ENABLED));
    this.context.put("pageTitle", forum.getName());
    this.context.put("canApproveMessages", canApproveMessages);
    this.context.put("replyOnly", !SecurityRepository.canAccess(SecurityConstants.PERM_REPLY_ONLY, Integer.toString(forum.getId())));
    this.context.put("readonly", !SecurityRepository.canAccess(SecurityConstants.PERM_READ_ONLY_FORUMS, Integer.toString(forumId)));
    this.context.put("watching", fm.isUserSubscribed(forumId, userSession.getUserId()));
    // Pagination
    int topicsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
    int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POSTS_PER_PAGE);
    int totalTopics = forum.getTotalTopics();
    ViewCommon.contextToPagination(start, totalTopics, topicsPerPage);
    this.context.put("postsPerPage", new Integer(postsPerPage));
    TopicsCommon.topicListingBase();
    this.context.put("moderator", isLogged && isModerator);
}
Also used : ForumDAO(net.jforum.dao.ForumDAO) HashMap(java.util.HashMap) ModerationDAO(net.jforum.dao.ModerationDAO) PostCommon(net.jforum.view.forum.common.PostCommon) UserSession(net.jforum.entities.UserSession) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Forum(net.jforum.entities.Forum)

Aggregations

HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ForumDAO (net.jforum.dao.ForumDAO)1 ModerationDAO (net.jforum.dao.ModerationDAO)1 Forum (net.jforum.entities.Forum)1 UserSession (net.jforum.entities.UserSession)1 PostCommon (net.jforum.view.forum.common.PostCommon)1