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;
}
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);
}
}
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;
}
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();
}
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();
}
Aggregations