Search in sources :

Example 6 with ModerationLog

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;
}
Also used : User(net.jforum.entities.User) ModerationLog(net.jforum.entities.ModerationLog) Date(java.util.Date)

Example 7 with ModerationLog

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);
}
Also used : PostDAO(net.jforum.dao.PostDAO) Post(net.jforum.entities.Post) ModerationLog(net.jforum.entities.ModerationLog) Iterator(java.util.Iterator) TopicDAO(net.jforum.dao.TopicDAO) List(java.util.List) ModerationLogDAO(net.jforum.dao.ModerationLogDAO) Topic(net.jforum.entities.Topic)

Example 8 with ModerationLog

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);
        }
    }
}
Also used : ForumDAO(net.jforum.dao.ForumDAO) ModerationLog(net.jforum.entities.ModerationLog) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) TopicDAO(net.jforum.dao.TopicDAO) ArrayList(java.util.ArrayList) List(java.util.List) Topic(net.jforum.entities.Topic)

Example 9 with ModerationLog

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;
}
Also used : User(net.jforum.entities.User) ModerationLog(net.jforum.entities.ModerationLog) RequestContext(net.jforum.context.RequestContext)

Aggregations

ModerationLog (net.jforum.entities.ModerationLog)9 Topic (net.jforum.entities.Topic)5 PostDAO (net.jforum.dao.PostDAO)4 TopicDAO (net.jforum.dao.TopicDAO)4 Post (net.jforum.entities.Post)4 Iterator (java.util.Iterator)2 List (java.util.List)2 RequestContext (net.jforum.context.RequestContext)2 ForumDAO (net.jforum.dao.ForumDAO)2 User (net.jforum.entities.User)2 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 KarmaDAO (net.jforum.dao.KarmaDAO)1 ModerationLogDAO (net.jforum.dao.ModerationLogDAO)1 PollDAO (net.jforum.dao.PollDAO)1 Poll (net.jforum.entities.Poll)1 PollChanges (net.jforum.entities.PollChanges)1 AttachmentException (net.jforum.exceptions.AttachmentException)1