Search in sources :

Example 1 with ModerationLogDAO

use of net.jforum.dao.ModerationLogDAO 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 2 with ModerationLogDAO

use of net.jforum.dao.ModerationLogDAO in project jforum2 by rafaelsteil.

the class ModerationHelper method saveModerationLog.

public void saveModerationLog(ModerationLog log) {
    ModerationLogDAO dao = DataAccessDriver.getInstance().newModerationLogDAO();
    dao.add(log);
}
Also used : ModerationLogDAO(net.jforum.dao.ModerationLogDAO)

Aggregations

ModerationLogDAO (net.jforum.dao.ModerationLogDAO)2 Iterator (java.util.Iterator)1 List (java.util.List)1 PostDAO (net.jforum.dao.PostDAO)1 TopicDAO (net.jforum.dao.TopicDAO)1 ModerationLog (net.jforum.entities.ModerationLog)1 Post (net.jforum.entities.Post)1 Topic (net.jforum.entities.Topic)1