use of net.jforum.entities.ModerationLog in project jforum2 by rafaelsteil.
the class GenericModerationLogDAO method makeLog.
protected ModerationLog makeLog(ResultSet rs) throws SQLException {
ModerationLog log = new ModerationLog();
log.setId(rs.getInt("log_id"));
log.setDescription(this.readDesriptionFromResultSet(rs));
log.setOriginalMessage(this.readOriginalMessageFromResultSet(rs));
log.setType(rs.getInt("log_type"));
log.setDate(new Date(rs.getTimestamp("log_date").getTime()));
log.setPostId(rs.getInt("post_id"));
log.setTopicId(rs.getInt("topic_id"));
User user = new User();
user.setId(rs.getInt("user_id"));
user.setUsername(rs.getString("username"));
log.setUser(user);
User posterUser = new User();
posterUser.setId(rs.getInt("post_user_id"));
posterUser.setUsername(rs.getString("poster_username"));
log.setPosterUser(posterUser);
return log;
}
use of net.jforum.entities.ModerationLog in project jforum2 by rafaelsteil.
the class ModerationAction method showActivityLog.
public void showActivityLog() {
if (!SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_LOG)) {
this.denied();
return;
}
ModerationLogDAO dao = DataAccessDriver.getInstance().newModerationLogDAO();
int start = ViewCommon.getStartPage();
int recordsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
List list = dao.selectAll(start, recordsPerPage);
boolean canAccessFullModerationLog = SecurityRepository.canAccess(SecurityConstants.PERM_FULL_MODERATION_LOG);
PostDAO postDao = DataAccessDriver.getInstance().newPostDAO();
TopicDAO topicDao = DataAccessDriver.getInstance().newTopicDAO();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
ModerationLog log = (ModerationLog) iter.next();
if (log.getPostId() > 0) {
Post post = postDao.selectById(log.getPostId());
if (post.getId() > 0 && ForumRepository.getForum(post.getForumId()) == null) {
iter.remove();
continue;
}
} else if (log.getTopicId() > 0) {
Topic topic = topicDao.selectRaw(log.getTopicId());
if (topic.getId() > 0 && ForumRepository.getForum(topic.getForumId()) == null) {
iter.remove();
continue;
}
}
if (log.getOriginalMessage() != null && canAccessFullModerationLog) {
Post post = new Post();
post.setText(log.getOriginalMessage());
log.setOriginalMessage(PostCommon.preparePostForDisplay(post).getText());
}
}
this.setTemplateName(TemplateKeys.MODERATION_SHOW_ACTIVITY_LOG);
this.context.put("activityLog", list);
this.context.put("canAccessFullModerationLog", canAccessFullModerationLog);
int totalRecords = dao.totalRecords();
ViewCommon.contextToPagination(start, totalRecords, recordsPerPage);
}
use of net.jforum.entities.ModerationLog in project jforum2 by rafaelsteil.
the class ModerationHelper method removeTopics.
private void removeTopics() {
String[] topics = JForumExecutionContext.getRequest().getParameterValues("topic_id");
List forumsList = new ArrayList();
TopicDAO tm = DataAccessDriver.getInstance().newTopicDAO();
List topicsToDelete = new ArrayList();
if (topics != null && topics.length > 0) {
ModerationLog log = this.buildModerationLogFromRequest();
for (int i = 0; i < topics.length; i++) {
Topic t = tm.selectRaw(Integer.parseInt(topics[i]));
log.setTopicId(t.getId());
log.setPosterUser(t.getPostedBy());
this.saveModerationLog(log);
if (!forumsList.contains(new Integer(t.getForumId()))) {
forumsList.add(new Integer(t.getForumId()));
}
topicsToDelete.add(t);
PostRepository.clearCache(t.getId());
}
tm.deleteTopics(topicsToDelete, false);
ForumDAO fm = DataAccessDriver.getInstance().newForumDAO();
TopicRepository.loadMostRecentTopics();
// Reload changed forums
for (Iterator iter = forumsList.iterator(); iter.hasNext(); ) {
int forumId = ((Integer) iter.next()).intValue();
TopicRepository.clearCache(forumId);
int postId = fm.getMaxPostId(forumId);
if (postId > -1) {
fm.setLastPost(forumId, postId);
} else {
logger.warn("Could not find last post id for forum " + forumId);
}
ForumRepository.reloadForum(forumId);
}
}
}
use of net.jforum.entities.ModerationLog in project jforum2 by rafaelsteil.
the class ModerationHelper method buildModerationLogFromRequest.
public ModerationLog buildModerationLogFromRequest() {
RequestContext request = JForumExecutionContext.getRequest();
ModerationLog log = new ModerationLog();
User user = new User();
user.setId(SessionFacade.getUserSession().getUserId());
log.setUser(user);
log.setDescription(request.getParameter("log_description"));
log.setOriginalMessage(request.getParameter("log_original_message"));
log.setType(request.getIntParameter("log_type"));
if (request.getParameter("post_id") != null) {
log.setPostId(request.getIntParameter("post_id"));
}
String[] values = request.getParameterValues("topic_id");
if (values != null && values.length == 1) {
log.setTopicId(request.getIntParameter("topic_id"));
}
return log;
}
Aggregations