/*
* Copyright (c) JForum Team
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* 1) Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* 2) Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* 3) Neither the name of "Rafael Steil" nor
* the names of its contributors may be used to endorse
* or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*
* This file creation date: May 3, 2003 / 5:05:18 PM
* The JForum Project
* http://www.jforum.net
*/
package net.jforum.view.forum;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.jforum.Command;
import net.jforum.JForumExecutionContext;
import net.jforum.SessionFacade;
import net.jforum.context.RequestContext;
import net.jforum.dao.AttachmentDAO;
import net.jforum.dao.DataAccessDriver;
import net.jforum.dao.ForumDAO;
import net.jforum.dao.KarmaDAO;
import net.jforum.dao.PollDAO;
import net.jforum.dao.PostDAO;
import net.jforum.dao.TopicDAO;
import net.jforum.dao.UserDAO;
import net.jforum.entities.Attachment;
import net.jforum.entities.Forum;
import net.jforum.entities.ModerationLog;
import net.jforum.entities.Poll;
import net.jforum.entities.PollChanges;
import net.jforum.entities.Post;
import net.jforum.entities.QuotaLimit;
import net.jforum.entities.Topic;
import net.jforum.entities.User;
import net.jforum.entities.UserSession;
import net.jforum.exceptions.AttachmentException;
import net.jforum.exceptions.ForumException;
import net.jforum.repository.ForumRepository;
import net.jforum.repository.PostRepository;
import net.jforum.repository.RankingRepository;
import net.jforum.repository.SecurityRepository;
import net.jforum.repository.SmiliesRepository;
import net.jforum.repository.TopicRepository;
import net.jforum.security.PermissionControl;
import net.jforum.security.SecurityConstants;
import net.jforum.util.I18n;
import net.jforum.util.preferences.ConfigKeys;
import net.jforum.util.preferences.SystemGlobals;
import net.jforum.util.preferences.TemplateKeys;
import net.jforum.view.forum.common.AttachmentCommon;
import net.jforum.view.forum.common.ForumCommon;
import net.jforum.view.forum.common.PollCommon;
import net.jforum.view.forum.common.PostCommon;
import net.jforum.view.forum.common.TopicsCommon;
import net.jforum.view.forum.common.ViewCommon;
import org.apache.commons.lang.StringUtils;
import freemarker.template.SimpleHash;
/**
* @author Rafael Steil
* @version $Id: PostAction.java,v 1.198 2007/09/27 04:47:19 rafaelsteil Exp $
*/
public class PostAction extends Command
{
public PostAction() {
}
public PostAction(RequestContext request, SimpleHash templateContext) {
super.context = templateContext;
super.request = request;
}
public void list()
{
PostDAO postDao = DataAccessDriver.getInstance().newPostDAO();
PollDAO pollDao = DataAccessDriver.getInstance().newPollDAO();
TopicDAO topicDao = DataAccessDriver.getInstance().newTopicDAO();
UserSession us = SessionFacade.getUserSession();
int anonymousUser = SystemGlobals.getIntValue(ConfigKeys.ANONYMOUS_USER_ID);
boolean logged = SessionFacade.isLogged();
int topicId = this.request.getIntParameter("topic_id");
Topic topic = TopicRepository.getTopic(new Topic(topicId));
if (topic == null) {
topic = topicDao.selectById(topicId);
}
// The topic exists?
if (topic.getId() == 0) {
this.topicNotFound();
return;
}
// Shall we proceed?
Forum forum = ForumRepository.getForum(topic.getForumId());
if (!logged) {
if (forum == null || !ForumRepository.isCategoryAccessible(forum.getCategoryId())) {
this.setTemplateName(ViewCommon.contextToLogin());
return;
}
}
else if (!TopicsCommon.isTopicAccessible(topic.getForumId())) {
return;
}
int count = SystemGlobals.getIntValue(ConfigKeys.POSTS_PER_PAGE);
int start = ViewCommon.getStartPage();
PermissionControl pc = SecurityRepository.get(us.getUserId());
boolean moderatorCanEdit = false;
if (pc.canAccess(SecurityConstants.PERM_MODERATION_POST_EDIT)) {
moderatorCanEdit = true;
}
List helperList = PostCommon.topicPosts(postDao, moderatorCanEdit, us.getUserId(), topic.getId(), start, count);
// Ugly assumption:
// Is moderation pending for the topic?
if (topic.isModerated() && helperList.size() == 0) {
this.notModeratedYet();
return;
}
// Set the topic status as read
if (logged) {
topicDao.updateReadStatus(topic.getId(), us.getUserId(), true);
}
boolean canVoteOnPoll = logged && SecurityRepository.canAccess(SecurityConstants.PERM_VOTE);
Poll poll = null;
if (topic.isVote()) {
// It has a poll associated with the topic
poll = pollDao.selectById(topic.getVoteId());
if (canVoteOnPoll) {
canVoteOnPoll = !pollDao.hasUserVotedOnPoll(topic.getVoteId(), us.getUserId());
}
}
topicDao.incrementTotalViews(topic.getId());
topic.setTotalViews(topic.getTotalViews() + 1);
if (us.getUserId() != anonymousUser) {
SessionFacade.getTopicsReadTime().put(new Integer(topic.getId()),
new Long(System.currentTimeMillis()));
}
boolean karmaEnabled = SecurityRepository.canAccess(SecurityConstants.PERM_KARMA_ENABLED);
Map userVotes = new HashMap();
if (logged && karmaEnabled) {
userVotes = DataAccessDriver.getInstance().newKarmaDAO().getUserVotes(topic.getId(), us.getUserId());
}
this.setTemplateName(TemplateKeys.POSTS_LIST);
this.context.put("attachmentsEnabled", pc.canAccess(
SecurityConstants.PERM_ATTACHMENTS_ENABLED, Integer.toString(topic.getForumId())));
this.context.put("canDownloadAttachments", pc.canAccess(
SecurityConstants.PERM_ATTACHMENTS_DOWNLOAD));
this.context.put("thumbShowBox", SystemGlobals.getBoolValue(ConfigKeys.ATTACHMENTS_IMAGES_THUMB_BOX_SHOW));
this.context.put("am", new AttachmentCommon(this.request, topic.getForumId()));
this.context.put("karmaVotes", userVotes);
this.context.put("rssEnabled", SystemGlobals.getBoolValue(ConfigKeys.RSS_ENABLED));
this.context.put("canRemove", pc.canAccess(SecurityConstants.PERM_MODERATION_POST_REMOVE));
this.context.put("moderatorCanEdit", moderatorCanEdit);
this.context.put("allCategories", ForumCommon.getAllCategoriesAndForums(false));
this.context.put("topic", topic);
this.context.put("poll", poll);
this.context.put("canVoteOnPoll", canVoteOnPoll);
this.context.put("rank", new RankingRepository());
this.context.put("posts", helperList);
this.context.put("forum", forum);
this.context.put("karmaMin", new Integer(SystemGlobals.getValue(ConfigKeys.KAR
没有合适的资源?快使用搜索试试~ 我知道了~
jforum-2.1.8-src.zip_JForum-2.1.8_The Watch_jforum_jforum 2.1.8-
共1304个文件
class:384个
java:361个
gif:203个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 116 浏览量
2022-09-19
16:03:01
上传
评论
收藏 16.38MB ZIP 举报
温馨提示
Personally think is the best forum for the Java source code, open source, you can watch the official website of the latest developments http://www.jforum.net/
资源推荐
资源详情
资源评论
收起资源包目录
jforum-2.1.8-src.zip_JForum-2.1.8_The Watch_jforum_jforum 2.1.8- (1304个子文件)
LuceneCommandLineReindexer.bat 157B
LuceneCommandLineReindexer.bat 157B
phpbb2JForum.bat 104B
phpbb2JForum.bat 99B
phpbb2JForum.bat 99B
PostAction.class 31KB
InstallAction.class 24KB
GenericTopicDAO.class 21KB
GenericUserDAO.class 20KB
UserAction.class 20KB
GenericForumDAO.class 16KB
ForumRepository.class 16KB
GenericAttachmentDAO.class 15KB
ConfigKeys.class 13KB
AttachmentCommon.class 12KB
User.class 11KB
Main.class 11KB
GenericPostDAO.class 11KB
ForumAction.class 10KB
PrivateMessageAction.class 9KB
WebRequestContext.class 9KB
Spammer.class 9KB
ControllerUtils.class 9KB
FileUploadBase.class 9KB
JForum.class 9KB
GenericPollDAO.class 8KB
ModerationHelper.class 8KB
GenericPrivateMessageDAO.class 8KB
ForumAction.class 8KB
PostCommon.class 8KB
SessionFacade.class 8KB
GenericKarmaDAO.class 8KB
POPListenerTestCase.class 8KB
AttachmentsAction.class 8KB
TemplateKeys.class 7KB
LuceneIndexer.class 7KB
LuceneSearch.class 7KB
UserCommon.class 7KB
TopicsCommon.class 7KB
DiskFileItem.class 7KB
BookmarkAction.class 7KB
AjaxAction.class 7KB
ConfigLoader.class 7KB
GenericGroupSecurityDAO.class 7KB
SystemGlobals.class 7KB
UserSession.class 7KB
I18n.class 7KB
MySQLVersionWorkarounder.class 6KB
XMLPermissionControl.class 6KB
UserAction.class 6KB
MultipartStream.class 6KB
GenericDataAccessDriver.class 6KB
GenericBookmarkDAO.class 6KB
POPPostAction.class 6KB
LuceneCommandLineReindexer.class 6KB
Captcha.class 6KB
LuceneStatsAction.class 6KB
TopicRepository.class 6KB
Topic.class 6KB
FakeHttpRequest.class 6KB
AdminAction.class 6KB
Post.class 6KB
POPMessage.class 6KB
ImageUtils.class 6KB
Category.class 6KB
CategoryAction.class 5KB
JForumExecutionContext.class 5KB
LuceneReindexer.class 5KB
ModerationAction.class 5KB
GenericBannerDAO.class 5KB
ViewCommon.class 5KB
SafeHtml.class 5KB
SecurityRepository.class 5KB
GenericCategoryDAO.class 5KB
ForumCommon.class 5KB
GroupAction.class 5KB
LuceneSearchTestCase.class 5KB
InstallServlet.class 5KB
JForumBaseServlet.class 5KB
GenericLuceneDAO.class 5KB
GenericModerationDAO.class 5KB
GenericGroupDAO.class 5KB
ConfigAction.class 5KB
GenericModerationLogDAO.class 5KB
EhCacheEngine.class 5KB
ConfigKeys.class 5KB
BBCodeHandler.class 4KB
MySQL323GroupSecurityDAO.class 4KB
ModerationAction.class 4KB
RSSAction.class 4KB
HottestTopicsAction.class 4KB
RecentTopicsAction.class 4KB
KarmaAction.class 4KB
SqlServerPostDAO.class 4KB
SmiliesAction.class 4KB
PostRepository.class 4KB
GenericMailIntegrationDAO.class 4KB
SearchAction.class 4KB
C3P0PooledConnection.class 4KB
SecurityCommon.class 4KB
共 1304 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14
资源评论
钱亚锋
- 粉丝: 86
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功