Search in sources :

Example 1 with Forum

use of net.jforum.entities.Forum in project jforum2 by rafaelsteil.

the class GenericForumDAO method fillForum.

protected Forum fillForum(ResultSet rs) throws SQLException {
    Forum f = new Forum();
    f.setId(rs.getInt("forum_id"));
    f.setIdCategories(rs.getInt("categories_id"));
    f.setName(rs.getString("forum_name"));
    f.setDescription(rs.getString("forum_desc"));
    f.setOrder(rs.getInt("forum_order"));
    f.setTotalTopics(rs.getInt("forum_topics"));
    f.setLastPostId(rs.getInt("forum_last_post_id"));
    f.setModerated(rs.getInt("moderated") > 0);
    f.setTotalPosts(this.countForumPosts(f.getId()));
    return f;
}
Also used : Forum(net.jforum.entities.Forum)

Example 2 with Forum

use of net.jforum.entities.Forum in project jforum2 by rafaelsteil.

the class GenericForumDAO method moveTopics.

/**
	 * @see net.jforum.dao.ForumDAO#moveTopics(java.lang.String[], int, int)
	 */
public void moveTopics(String[] topics, int fromForumId, int toForumId) {
    PreparedStatement p = null;
    PreparedStatement t = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.moveTopics"));
        t = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.setForumByTopic"));
        p.setInt(1, toForumId);
        p.setInt(2, fromForumId);
        t.setInt(1, toForumId);
        TopicDAO tdao = DataAccessDriver.getInstance().newTopicDAO();
        Forum f = this.selectById(toForumId);
        for (int i = 0; i < topics.length; i++) {
            int topicId = Integer.parseInt(topics[i]);
            p.setInt(3, topicId);
            t.setInt(2, topicId);
            p.executeUpdate();
            t.executeUpdate();
            tdao.setModerationStatusByTopic(topicId, f.isModerated());
        }
        this.decrementTotalTopics(fromForumId, topics.length);
        this.incrementTotalTopics(toForumId, topics.length);
        this.setLastPost(fromForumId, this.getMaxPostId(fromForumId));
        this.setLastPost(toForumId, this.getMaxPostId(toForumId));
    } catch (SQLException e) {
        throw new DatabaseException(e);
    } finally {
        DbUtils.close(p);
        DbUtils.close(t);
    }
}
Also used : SQLException(java.sql.SQLException) TopicDAO(net.jforum.dao.TopicDAO) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException) Forum(net.jforum.entities.Forum)

Example 3 with Forum

use of net.jforum.entities.Forum in project jforum2 by rafaelsteil.

the class SearchOperation method filterResults.

public final List filterResults(List results) {
    List l = new ArrayList();
    Map forums = new HashMap();
    for (Iterator iter = results.iterator(); iter.hasNext(); ) {
        Object currentObject = iter.next();
        Integer forumId = new Integer(this.extractForumId(currentObject));
        ForumFilterResult status = (ForumFilterResult) forums.get(forumId);
        if (status == null) {
            Forum f = ForumRepository.getForum(forumId.intValue());
            status = new ForumFilterResult(f);
            forums.put(forumId, status);
        }
        if (status.isValid()) {
            // TODO: decouple
            if (currentObject instanceof SearchPost) {
                ((SearchPost) currentObject).setForum(status.getForum());
            }
            l.add(currentObject);
        }
    }
    return l;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Forum(net.jforum.entities.Forum)

Example 4 with Forum

use of net.jforum.entities.Forum in project jforum2 by rafaelsteil.

the class ForumAction method editSave.

public void editSave() {
    ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO();
    Forum f = forumDao.selectById(this.request.getIntParameter("forum_id"));
    boolean moderated = f.isModerated();
    int categoryId = f.getCategoryId();
    f.setDescription(this.request.getParameter("description"));
    f.setIdCategories(this.request.getIntParameter("categories_id"));
    f.setName(this.request.getParameter("forum_name"));
    f.setModerated("1".equals(this.request.getParameter("moderate")));
    forumDao.update(f);
    if (moderated != f.isModerated()) {
        new ModerationCommon().setTopicModerationStatus(f.getId(), f.isModerated());
    }
    if (categoryId != f.getCategoryId()) {
        f.setIdCategories(categoryId);
        ForumRepository.removeForum(f);
        f.setIdCategories(this.request.getIntParameter("categories_id"));
        ForumRepository.addForum(f);
    } else {
        ForumRepository.reloadForum(f.getId());
    }
    //this.handleMailIntegration();
    this.list();
}
Also used : ForumDAO(net.jforum.dao.ForumDAO) ModerationCommon(net.jforum.view.admin.common.ModerationCommon) Forum(net.jforum.entities.Forum)

Example 5 with Forum

use of net.jforum.entities.Forum in project jforum2 by rafaelsteil.

the class ForumAction method delete.

// Delete
public void delete() {
    String[] ids = this.request.getParameterValues("forum_id");
    ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO();
    TopicDAO topicDao = DataAccessDriver.getInstance().newTopicDAO();
    if (ids != null) {
        for (int i = 0; i < ids.length; i++) {
            int forumId = Integer.parseInt(ids[i]);
            topicDao.deleteByForum(forumId);
            forumDao.delete(forumId);
            Forum f = new Forum(ForumRepository.getForum(forumId));
            ForumRepository.removeForum(f);
        }
        SecurityRepository.clean();
        RolesRepository.clear();
    }
    this.list();
}
Also used : ForumDAO(net.jforum.dao.ForumDAO) TopicDAO(net.jforum.dao.TopicDAO) Forum(net.jforum.entities.Forum)

Aggregations

Forum (net.jforum.entities.Forum)28 List (java.util.List)14 Iterator (java.util.Iterator)13 Map (java.util.Map)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 Topic (net.jforum.entities.Topic)8 Category (net.jforum.entities.Category)7 ForumDAO (net.jforum.dao.ForumDAO)5 TopicDAO (net.jforum.dao.TopicDAO)5 User (net.jforum.entities.User)5 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)4 PostDAO (net.jforum.dao.PostDAO)3 UserDAO (net.jforum.dao.UserDAO)3 UserSession (net.jforum.entities.UserSession)3 PermissionControl (net.jforum.security.PermissionControl)3 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Set (java.util.Set)2