use of net.jforum.dao.ForumDAO 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.dao.ForumDAO 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();
}
use of net.jforum.dao.ForumDAO in project jforum2 by rafaelsteil.
the class ForumAction method processOrdering.
private void processOrdering(boolean up) {
Forum toChange = new Forum(ForumRepository.getForum(Integer.parseInt(this.request.getParameter("forum_id"))));
Category category = ForumRepository.getCategory(toChange.getCategoryId());
List forums = new ArrayList(category.getForums());
int index = forums.indexOf(toChange);
if (index == -1 || (up && index == 0) || (!up && index + 1 == forums.size())) {
this.list();
return;
}
ForumDAO fm = DataAccessDriver.getInstance().newForumDAO();
if (up) {
// Get the forum which comes *before* the forum we're changing
Forum otherForum = new Forum((Forum) forums.get(index - 1));
fm.setOrderUp(toChange, otherForum);
} else {
// Get the forum which comes *after* the forum we're changing
Forum otherForum = new Forum((Forum) forums.get(index + 1));
fm.setOrderDown(toChange, otherForum);
}
category.changeForumOrder(toChange);
ForumRepository.refreshCategory(category);
this.list();
}
use of net.jforum.dao.ForumDAO in project jforum2 by rafaelsteil.
the class GenericTopicDAO method deleteTopics.
public void deleteTopics(List topics, boolean fromModeration) {
// Topic
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.delete"));
ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO();
PostDAO postDao = DataAccessDriver.getInstance().newPostDAO();
PollDAO pollDao = DataAccessDriver.getInstance().newPollDAO();
for (Iterator iter = topics.iterator(); iter.hasNext(); ) {
Topic topic = (Topic) iter.next();
// Remove watches
this.removeSubscriptionByTopic(topic.getId());
// Remove the messages
postDao.deleteByTopic(topic.getId());
// Remove the poll
pollDao.deleteByTopicId(topic.getId());
// Delete the topic itself
p.setInt(1, topic.getId());
p.executeUpdate();
if (!fromModeration) {
forumDao.decrementTotalTopics(topic.getForumId(), 1);
}
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.dao.ForumDAO in project jforum2 by rafaelsteil.
the class ForumStartup method startForumRepository.
/**
* Starts the cache control for forums and categories.
* @throws RepositoryStartupException is something were wrong.
*/
public static void startForumRepository() {
try {
ForumDAO fm = DataAccessDriver.getInstance().newForumDAO();
CategoryDAO cm = DataAccessDriver.getInstance().newCategoryDAO();
ConfigDAO configModel = DataAccessDriver.getInstance().newConfigDAO();
ForumRepository.start(fm, cm, configModel);
} catch (Exception e) {
log.error("Unable to bootstrap JForum repository.", e);
throw new RepositoryStartupException("Error while trying to start ForumRepository: " + e, e);
}
}
Aggregations