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