/*
* Copyright (c) 2003, 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.List;
import java.util.Map;
import net.jforum.Command;
import net.jforum.JForum;
import net.jforum.SessionFacade;
import net.jforum.entities.Attachment;
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.model.AttachmentModel;
import net.jforum.model.DataAccessDriver;
import net.jforum.model.ForumModel;
import net.jforum.model.PostModel;
import net.jforum.model.TopicModel;
import net.jforum.model.UserModel;
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.view.forum.common.AttachmentCommon;
import net.jforum.view.forum.common.ForumCommon;
import net.jforum.view.forum.common.PostCommon;
import net.jforum.view.forum.common.TopicsCommon;
import net.jforum.view.forum.common.ViewCommon;
import org.apache.log4j.Logger;
/**
* @author Rafael Steil
* @version $Id: PostAction.java,v 1.68 2005/03/04 14:14:48 rafaelsteil Exp $
*/
public class PostAction extends Command {
private static final Logger logger = Logger.getLogger(PostAction.class);
public void list() throws Exception {
PostModel pm = DataAccessDriver.getInstance().newPostModel();
UserModel um = DataAccessDriver.getInstance().newUserModel();
TopicModel tm = DataAccessDriver.getInstance().newTopicModel();
int userId = SessionFacade.getUserSession().getUserId();
int anonymousUser = SystemGlobals.getIntValue(ConfigKeys.ANONYMOUS_USER_ID);
int topicId = this.request.getIntParameter("topic_id");
Topic topic = tm.selectById(topicId);
// The topic exists?
if (topic.getId() == 0) {
this.topicNotFound();
return;
}
// Shall we proceed?
if (!TopicsCommon.isTopicAccessible(topic.getForumId())) {
return;
}
int count = SystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE);
int start = ViewCommon.getStartPage();
PermissionControl pc = SecurityRepository.get(userId);
boolean canEdit = false;
if (pc.canAccess(SecurityConstants.PERM_MODERATION_POST_EDIT)) {
canEdit = true;
}
Map usersMap = new HashMap();
List helperList = PostCommon.topicPosts(pm, um, usersMap, canEdit, userId, topic.getId(), start, count);
// Ugly assumption:
// Is moderation pending for the topic?
if (topic.isModerated() && helperList.size() == 0) {
this.notModeratedYet();
return;
}
boolean isModerator = (pc.canAccess(SecurityConstants.PERM_MODERATION))
&& (pc.canAccess(SecurityConstants.PERM_MODERATION_FORUMS, Integer.toString(topic.getForumId())));
// Set the topic status as read
tm.updateReadStatus(topic.getId(), userId, true);
tm.incrementTotalViews(topic.getId());
if (userId != anonymousUser) {
((HashMap) SessionFacade.getAttribute(ConfigKeys.TOPICS_TRACKING)).put(new Integer(topic.getId()),
new Long(topic.getLastPostTimeInMillis().getTime()));
}
this.context.put("attachmentsEnabled", SecurityRepository.canAccess(
SecurityConstants.PERM_ATTACHMENTS_ENABLED, Integer.toString(topic.getForumId())));
this.context.put("canDownloadAttachments", SecurityRepository.canAccess(
SecurityConstants.PERM_ATTACHMENTS_DOWNLOAD));
this.context.put("am", new AttachmentCommon(this.request));
this.context.put("karmaVotes", DataAccessDriver.getInstance().newKarmaModel().getUserVotes(topic.getId(), userId));
this.context.put("rssEnabled", SystemGlobals.getBoolValue(ConfigKeys.RSS_ENABLED));
this.context.put("canRemove",
SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_POST_REMOVE));
this.context.put("canEdit", canEdit);
this.context.put("moduleAction", "post_show.htm");
this.context.put("allCategories", ForumCommon.getAllCategoriesAndForums(false));
this.context.put("topic", topic);
this.context.put("rank", new RankingRepository());
this.context.put("posts", helperList);
this.context.put("karmaEnabled", SecurityRepository.canAccess(SecurityConstants.PERM_KARMA_ENABLED));
this.context.put("forum", ForumRepository.getForum(topic.getForumId()));
this.context.put("users", usersMap);
this.context.put("topicId", new Integer(topicId));
this.context.put("anonymousPosts", SecurityRepository.canAccess(SecurityConstants.PERM_ANONYMOUS_POST,
Integer.toString(topic.getForumId())));
this.context.put("watching", tm.isUserSubscribed(topicId, SessionFacade.getUserSession().getUserId()));
this.context.put("pageTitle", SystemGlobals.getValue(ConfigKeys.FORUM_NAME) + " - " + topic.getTitle());
this.context.put("isAdmin", SecurityRepository.canAccess(SecurityConstants.PERM_ADMINISTRATION));
this.context.put("readonly", !SecurityRepository.canAccess(SecurityConstants.PERM_READ_ONLY_FORUMS,
Integer.toString(topic.getForumId())));
this.context.put("replyOnly", !SecurityRepository.canAccess(SecurityConstants.PERM_REPLY_ONLY,
Integer.toString(topic.getForumId())));
this.context.put("isModerator", SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION)
&& SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_FORUMS,
Integer.toString(topic.getForumId())));
// Topic Status
this.context.put("STATUS_LOCKED", new Integer(Topic.STATUS_LOCKED));
this.context.put("STATUS_UNLOCKED", new Integer(Topic.STATUS_UNLOCKED));
// Pagination
int totalPosts = tm.getTotalPosts(topic.getId());
this.co
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
JForum-2.1.4.rar_JForum-2.1.4_java 论坛源码_jforum_论坛源码_论坛网站源码 (860个子文件)
PostAction.class 22KB
InstallAction.class 19KB
UserModel.class 16KB
TopicModel.class 14KB
UserAction.class 14KB
AttachmentModel.class 13KB
ForumRepository.class 11KB
JForum.class 11KB
AttachmentCommon.class 10KB
ForumAction.class 9KB
User.class 9KB
ForumModel.class 9KB
PrivateMessageAction.class 9KB
ForumRepositoryTest.class 9KB
PostModel.class 8KB
UserAction.class 8KB
AttachmentsAction.class 8KB
PostCommon.class 8KB
SearchAction.class 8KB
ForumAction.class 8KB
TopicsCommon.class 7KB
PooledConnection.class 7KB
ConfigKeys.class 7KB
BookmarkAction.class 7KB
PrivateMessageModel.class 7KB
KarmaModel.class 7KB
ModerationHelper.class 6KB
CategoryAction.class 6KB
JForumCommonServlet.class 6KB
KarmaAction.class 6KB
UserCommon.class 6KB
ActionServletRequest.class 6KB
SessionFacade.class 6KB
Spammer.class 6KB
Category.class 6KB
FakeHttpRequest.class 6KB
I18n.class 5KB
DataAccessDriver.class 5KB
Post.class 5KB
GroupAction.class 5KB
BookmarkModel.class 5KB
XMLPermissionControl.class 5KB
UserSecurityModel.class 5KB
SystemGlobals.class 5KB
Topic.class 5KB
Captcha.class 5KB
SecurityRepository.class 5KB
SearchModel.class 5KB
PooledExecutor.class 5KB
UserSession.class 5KB
ConfigLoader.class 5KB
ModerationAction.class 5KB
CategoryOrderTest.class 5KB
RSSAction.class 5KB
TestCaseUtils.class 5KB
PermissionProcessHelper.class 5KB
InstallServlet.class 4KB
ImageUtils.class 4KB
PostRepository.class 4KB
SmiliesAction.class 4KB
CategoryModel.class 4KB
MergeTest.class 4KB
BBCodeHandler.class 4KB
ModerationModel.class 4KB
ConfigAction.class 4KB
QueuedExecutor.class 4KB
SafeHtml.class 4KB
TopicRepository.class 4KB
JBossCacheEngine.class 4KB
ForumRSS.class 4KB
ViewCommon.class 4KB
CacheAction.class 4KB
I18nTest.class 4KB
GroupModel.class 4KB
SearchIndexerModel.class 4KB
Forum.class 4KB
SecurityCommon.class 4KB
ForumCommon.class 4KB
GroupSecurityModel.class 4KB
DataAccessDriver.class 4KB
AdminAction.class 3KB
DataAccessDriver.class 3KB
DataAccessDriver.class 3KB
ForumOrderTest.class 3KB
SmilieModel.class 3KB
RankingAction.class 3KB
UserSecurityHelper.class 3KB
AttachmentInfo.class 3KB
RankingModel.class 3KB
PostModel.class 3KB
ConfigModel.class 3KB
UserSessionModel.class 3KB
AutoKeys.class 3KB
JForumCommonServlet$DataHolder.class 3KB
SimpleResult.class 3KB
TopicRSS.class 3KB
TopicPostsRSS.class 3KB
TopicSpammer.class 3KB
PermissionControl.class 3KB
SearchData.class 3KB
共 860 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
weixin_42653672
- 粉丝: 93
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功