Search in sources :

Example 11 with ForumDAO

use of net.jforum.dao.ForumDAO 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 12 with ForumDAO

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

the class ForumAction method edit.

// Edit
public void edit() {
    int forumId = this.request.getIntParameter("forum_id");
    ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO();
    CategoryDAO cm = DataAccessDriver.getInstance().newCategoryDAO();
    this.setTemplateName(TemplateKeys.FORUM_ADMIN_EDIT);
    this.context.put("categories", cm.selectAll());
    this.context.put("action", "editSave");
    this.context.put("forum", forumDao.selectById(forumId));
// Mail Integration
// MailIntegrationDAO integrationDao = DataAccessDriver.getInstance().newMailIntegrationDAO();
// this.context.put("mailIntegration", integrationDao.find(forumId));
}
Also used : ForumDAO(net.jforum.dao.ForumDAO) CategoryDAO(net.jforum.dao.CategoryDAO)

Example 13 with ForumDAO

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

the class AdminAction method main.

public void main() throws Exception {
    if (this.checkAdmin()) {
        this.setTemplateName(TemplateKeys.ADMIN_MAIN);
        // Checks if the install module is still active
        this.context.put("installModuleExists", ModulesRepository.getModuleClass("install") != null);
        this.context.put("sessions", SessionFacade.getAllSessions());
        ForumDAO dao = DataAccessDriver.getInstance().newForumDAO();
        this.context.put("stats", dao.getBoardStatus());
        this.checkBoardVersion();
    }
}
Also used : ForumDAO(net.jforum.dao.ForumDAO)

Aggregations

ForumDAO (net.jforum.dao.ForumDAO)13 TopicDAO (net.jforum.dao.TopicDAO)5 Forum (net.jforum.entities.Forum)5 Topic (net.jforum.entities.Topic)5 List (java.util.List)4 PostDAO (net.jforum.dao.PostDAO)4 ArrayList (java.util.ArrayList)3 Post (net.jforum.entities.Post)3 Date (java.util.Date)2 Iterator (java.util.Iterator)2 CategoryDAO (net.jforum.dao.CategoryDAO)2 PollDAO (net.jforum.dao.PollDAO)2 ModerationLog (net.jforum.entities.ModerationLog)2 User (net.jforum.entities.User)2 UserSession (net.jforum.entities.UserSession)2 DatabaseException (net.jforum.exceptions.DatabaseException)2 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)2 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 SimpleDateFormat (java.text.SimpleDateFormat)1