/*
* Copyright (c) Rafael Steil
* 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.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.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.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.AttachmentSizeTooBigException;
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;
/**
* @author Rafael Steil
* @version $Id: PostAction.java,v 1.141 2006/02/21 13:59:49 rafaelsteil Exp $
*/
public class PostAction extends Command
{
public void list() throws Exception
{
PostDAO pm = DataAccessDriver.getInstance().newPostDAO();
PollDAO pollDao = DataAccessDriver.getInstance().newPollDAO();
UserDAO um = DataAccessDriver.getInstance().newUserDAO();
TopicDAO tm = 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 = tm.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.POST_PER_PAGE);
int start = ViewCommon.getStartPage();
PermissionControl pc = SecurityRepository.get(us.getUserId());
boolean canEdit = false;
if (pc.canAccess(SecurityConstants.PERM_MODERATION_POST_EDIT)) {
canEdit = true;
}
List helperList = PostCommon.topicPosts(pm, canEdit, 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) {
tm.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());
}
}
tm.incrementTotalViews(topic.getId());
topic.setTotalViews(topic.getTotalViews() + 1);
if (us.getUserId() != anonymousUser) {
((Map)SessionFacade.getAttribute(ConfigKeys.TOPICS_TRACKING)).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("canEdit", canEdit);
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);
Map topicPosters = tm.topicPosters(topic.getId());
for (Iterator iter = topicPosters.values().iterator(); iter.hasNext(); ) {
Vi
没有合适的资源?快使用搜索试试~ 我知道了~
JForum-2.1.6-src.zip_JForum-2.1.4_JForum-2.1.6-src_ejb_jforum_jf
共1088个文件
class:355个
java:310个
gif:179个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 56 浏览量
2022-09-23
22:59:39
上传
评论
收藏 16.9MB ZIP 举报
温馨提示
JForum 是一个功能强大 ,易于管理的论坛。它的设计完全遵从MVC设计模式,能够在任何Servlet容器与EJB服务器上运行。而且可以轻松的定制与扩展JForum论坛。
资源推荐
资源详情
资源评论
收起资源包目录
JForum-2.1.6-src.zip_JForum-2.1.4_JForum-2.1.6-src_ejb_jforum_jf (1088个子文件)
PostAction.class 29KB
InstallAction.class 19KB
GenericTopicDAO.class 17KB
UserAction.class 17KB
GenericUserDAO.class 16KB
ForumRepository.class 15KB
GenericForumDAO.class 14KB
GenericAttachmentDAO.class 13KB
AttachmentCommon.class 12KB
ConfigKeys.class 11KB
User.class 11KB
ForumAction.class 10KB
PrivateMessageAction.class 10KB
FileUploadBase.class 9KB
ForumRepositoryTest.class 9KB
ControllerUtils.class 8KB
SearchAction.class 8KB
GenericPostDAO.class 8KB
TopicsCommon.class 8KB
AttachmentsAction.class 8KB
JForum.class 7KB
SessionFacade.class 7KB
GenericPollDAO.class 7KB
DiskFileItem.class 7KB
GenericPrivateMessageDAO.class 7KB
BookmarkAction.class 7KB
Spammer.class 7KB
ForumAction.class 7KB
GenericKarmaDAO.class 7KB
PostCommon.class 7KB
ActionServletRequest.class 7KB
ModerationHelper.class 7KB
UserSession.class 6KB
TemplateKeys.class 6KB
MultipartStream.class 6KB
XMLPermissionControl.class 6KB
GenericSearchDAO.class 6KB
UserCommon.class 6KB
TopicRepository.class 6KB
RSSAction.class 6KB
FakeHttpRequest.class 6KB
I18n.class 6KB
Captcha.class 6KB
GenericDataAccessDriver.class 6KB
Topic.class 6KB
DatabaseWorkarounder.class 6KB
UserAction.class 6KB
Post.class 6KB
CategoryAction.class 6KB
Category.class 6KB
ConfigLoader.class 6KB
SystemGlobals.class 6KB
GenericGroupSecurityDAO.class 5KB
GenericSearchIndexerDAO.class 5KB
ViewCommon.class 5KB
JForumExecutionContext.class 5KB
ModerationAction.class 5KB
AdminAction.class 5KB
GenericBookmarkDAO.class 5KB
SecurityRepository.class 5KB
PooledExecutor.class 5KB
GroupAction.class 5KB
ForumCommon.class 5KB
TestCaseUtils.class 5KB
GenericBannerDAO.class 5KB
InstallServlet.class 5KB
CategoryOrderTest.class 5KB
EhCacheEngine.class 5KB
GenericScheduledSearchIndexerDAO.class 5KB
SafeHtml.class 4KB
GenericCategoryDAO.class 4KB
ImageUtils.class 4KB
ConfigAction.class 4KB
GenericModerationDAO.class 4KB
RecentTopicsAction.class 4KB
KarmaAction.class 4KB
BBCodeHandler.class 4KB
SmiliesAction.class 4KB
PostRepository.class 4KB
PermissionProcessHelper.class 4KB
JForumBaseServlet.class 4KB
QuartzSearchIndexerJob.class 4KB
QueuedExecutor.class 4KB
Banner.class 4KB
JBossCacheEngine.class 4KB
Forum.class 4KB
ForumRSS.class 4KB
GenericGroupDAO.class 4KB
ConfigLoader.class 4KB
I18nTest.class 4KB
CacheAction.class 4KB
SecurityCommon.class 4KB
GenericSummaryDAO.class 4KB
LDAPAuthenticator.class 3KB
ForumModelDummy.class 3KB
BannerAction.class 3KB
GenericSmilieDAO.class 3KB
OnlineUsersTest.class 3KB
ParameterParser.class 3KB
ForumOrderTest.class 3KB
共 1088 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
小波思基
- 粉丝: 70
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 历届(第1-21届)希望杯数学竞赛初一试题及答案(最新整理).doc全国数学邀请赛(264页资料)
- 水滴.psd
- TokenPocket_V2.1.2_release.apk
- Apache-druid-kafka-rce.yaml
- 半导体行业词汇 相关缩写
- 基于C#的ASP.NET数据库原理及应用技术课程指导平台的开发
- 基于ROS的智能车轨迹跟踪算法的仿真与设计源码运用PID跟踪算法.zip.zip
- Bug Bounty Tip - i春秋Self-XSS变废为宝的奇思妙想
- 1991-2015年全国初中化学竞赛复赛试题汇编(212页)(24年竞赛复赛真题).docx天原杯
- Apache Flink 未授权访问+远程代码执行.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功