Search in sources :

Example 21 with PostDAO

use of net.jforum.dao.PostDAO in project jforum2 by rafaelsteil.

the class PostAction method quote.

public void quote() {
    PostDAO pm = DataAccessDriver.getInstance().newPostDAO();
    Post p = pm.selectById(this.request.getIntParameter("post_id"));
    if (p.getId() == 0) {
        this.postNotFound();
        return;
    }
    if (p.isModerationNeeded()) {
        this.notModeratedYet();
        return;
    }
    if (!this.anonymousPost(p.getForumId())) {
        return;
    }
    Topic topic = TopicRepository.getTopic(new Topic(p.getTopicId()));
    if (topic == null) {
        topic = DataAccessDriver.getInstance().newTopicDAO().selectRaw(p.getTopicId());
    }
    if (!TopicsCommon.isTopicAccessible(topic.getForumId())) {
        return;
    }
    if (topic.getStatus() == Topic.STATUS_LOCKED) {
        this.topicLocked();
        return;
    }
    this.setTemplateName(TemplateKeys.POSTS_QUOTE);
    this.context.put("forum", ForumRepository.getForum(p.getForumId()));
    this.context.put("action", "insertSave");
    this.context.put("post", p);
    UserDAO um = DataAccessDriver.getInstance().newUserDAO();
    User u = um.selectById(p.getUserId());
    int userId = SessionFacade.getUserSession().getUserId();
    this.context.put("attachmentsEnabled", SecurityRepository.canAccess(SecurityConstants.PERM_ATTACHMENTS_ENABLED, Integer.toString(topic.getForumId())));
    QuotaLimit ql = new AttachmentCommon(this.request, topic.getForumId()).getQuotaLimit(userId);
    this.context.put("maxAttachmentsSize", new Long(ql != null ? ql.getSizeInBytes() : 1));
    this.context.put("moderationLoggingEnabled", SystemGlobals.getBoolValue(ConfigKeys.MODERATION_LOGGING_ENABLED));
    this.context.put("maxAttachments", SystemGlobals.getValue(ConfigKeys.ATTACHMENTS_MAX_POST));
    this.context.put("isNewPost", true);
    this.context.put("topic", topic);
    this.context.put("quote", "true");
    this.context.put("quoteUser", u.getUsername());
    this.context.put("setType", false);
    this.context.put("htmlAllowed", SecurityRepository.canAccess(SecurityConstants.PERM_HTML_DISABLED, Integer.toString(topic.getForumId())));
    this.context.put("start", this.request.getParameter("start"));
    this.context.put("user", DataAccessDriver.getInstance().newUserDAO().selectById(userId));
    this.context.put("pageTitle", I18n.getMessage("PostForm.reply") + " " + topic.getTitle());
    this.context.put("smilies", SmiliesRepository.getSmilies());
    boolean needCaptcha = SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS);
    if (needCaptcha) {
        SessionFacade.getUserSession().createNewCaptcha();
    }
    this.context.put("needCaptcha", needCaptcha);
}
Also used : User(net.jforum.entities.User) PostDAO(net.jforum.dao.PostDAO) UserDAO(net.jforum.dao.UserDAO) Post(net.jforum.entities.Post) Topic(net.jforum.entities.Topic) QuotaLimit(net.jforum.entities.QuotaLimit) AttachmentCommon(net.jforum.view.forum.common.AttachmentCommon)

Aggregations

PostDAO (net.jforum.dao.PostDAO)21 Post (net.jforum.entities.Post)15 Topic (net.jforum.entities.Topic)13 TopicDAO (net.jforum.dao.TopicDAO)10 List (java.util.List)8 User (net.jforum.entities.User)8 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)8 Iterator (java.util.Iterator)5 PollDAO (net.jforum.dao.PollDAO)5 Map (java.util.Map)4 ForumDAO (net.jforum.dao.ForumDAO)4 UserDAO (net.jforum.dao.UserDAO)4 ModerationLog (net.jforum.entities.ModerationLog)4 Poll (net.jforum.entities.Poll)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Forum (net.jforum.entities.Forum)3 AttachmentException (net.jforum.exceptions.AttachmentException)3 KarmaDAO (net.jforum.dao.KarmaDAO)2 QuotaLimit (net.jforum.entities.QuotaLimit)2