use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class InstallAction method storeSupportProjectMessage.
private void storeSupportProjectMessage(Connection connection) {
StringBuffer message = new StringBuffer("[color=#3AA315][size=18][b]Support JForum - Help the project[/b][/size][/color]").append("<hr>").append("This project is Open Source, and maintained by at least one full time Senior Developer, [i]which costs US$ 3,000.00 / month[/i]. ").append("If it helped you, please consider helping this project - especially with some [b][url=http://www.jforum.net/contribute.jsp]donation[/url][/b].").append('\n').append('\n').append("[color=#137C9F][size=14][b]Why supporting this project is a good thing[/b][/size][/color]").append("<hr>").append("The JForum Project started four years ago as a completely free and Open Source program, initially entirely developed on my (Rafael Steil) ").append("free time. Today, with the help of some very valuable people, I can spend more time on JForum, to improve it and implement new features ").append("(lots of things, requested either on the [url=http://www.jforum.net/forums/list.page]forums[/url] or registered in the ").append("[url=http://www.jforum.net/jira]bug tracker[/url]).").append('\n').append("That's why I'm asking you to financially support this work. I love Open Source. I love to use good products without having to pay for it too. ").append("But when I see some program that is valuable to my work, that helps me making money, I think it's a good idea to support this project.").append('\n').append('\n').append("[b]Some reasons to support open projects[/b]:").append("<ul><li>Because Open Source is cool? Yes").append("<li>To thank for a great tool? Yes").append("<li>To help the project evolve because this will help my work and my earnings? Yes</ul>").append("Also, as the project grows more and more, it would be great to, sometimes, reward some of the great people who help JForum.").append('\n').append('\n').append("So, that's what I'm asking you: if JForum helps your work, saves your time (time is money, remember?) and increase your earnings, support ").append("this project. The simpler way is to make [url=http://www.jforum.net/contribute.jsp]any donation[/url] via PayPal.").append('\n').append('\n').append("JForum has grown a lot every day, since four years ago, which is a great thing, and initially it wasn't my intention to fully work on this tool. ").append("Lately, I'm spending a lot of time on it, specially to make JForum 3 a reality, to help users, to improve the program, to research about ").append("better solutions. So, your support is very welcome!").append('\n').append('\n').append("Thanks!").append('\n').append('\n').append(":arrow: [size=16][b][url=http://www.jforum.net/contribute.jsp]Click here[/url][/b] to go to the [i][b][url=http://www.jforum.net/contribute.jsp]").append("\"Support JForum\"[/url][/b][/i] page.[/size]").append('\n').append('\n');
try {
ConfigLoader.createLoginAuthenticator();
ConfigLoader.loadDaoImplementation();
SystemGlobals.loadQueries(SystemGlobals.getValue(ConfigKeys.SQL_QUERIES_GENERIC));
SystemGlobals.loadQueries(SystemGlobals.getValue(ConfigKeys.SQL_QUERIES_DRIVER));
SystemGlobals.setValue(ConfigKeys.SEARCH_INDEXING_ENABLED, "false");
JForumExecutionContext ex = JForumExecutionContext.get();
ex.setConnection(connection);
JForumExecutionContext.set(ex);
User user = new User(2);
// Create topic
Topic topic = new Topic();
topic.setPostedBy(user);
topic.setTitle("Support JForum - Please read");
topic.setTime(new Date());
topic.setType(Topic.TYPE_ANNOUNCE);
topic.setForumId(1);
TopicDAO topicDao = DataAccessDriver.getInstance().newTopicDAO();
topicDao.addNew(topic);
// Create post
Post post = new Post();
post.setSubject(topic.getTitle());
post.setTime(topic.getTime());
post.setUserId(user.getId());
post.setText(message.toString());
post.setForumId(topic.getForumId());
post.setSmiliesEnabled(true);
post.setHtmlEnabled(true);
post.setBbCodeEnabled(true);
post.setUserIp("127.0.0.1");
post.setTopicId(topic.getId());
PostDAO postDao = DataAccessDriver.getInstance().newPostDAO();
postDao.addNew(post);
// Update topic
topic.setFirstPostId(post.getId());
topic.setLastPostId(post.getId());
topicDao.update(topic);
// Update forum stats
ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO();
forumDao.incrementTotalTopics(1, 1);
forumDao.setLastPost(1, post.getId());
} finally {
SystemGlobals.setValue(ConfigKeys.SEARCH_INDEXING_ENABLED, "true");
JForumExecutionContext ex = JForumExecutionContext.get();
ex.setConnection(null);
JForumExecutionContext.set(ex);
}
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class PostCommon method topicPosts.
public static List topicPosts(PostDAO dao, boolean canEdit, int userId, int topicId, int start, int count) {
boolean needPrepare = true;
List posts;
if (SystemGlobals.getBoolValue(ConfigKeys.POSTS_CACHE_ENABLED)) {
posts = PostRepository.selectAllByTopicByLimit(topicId, start, count);
needPrepare = false;
} else {
posts = dao.selectAllByTopicByLimit(topicId, start, count);
}
List helperList = new ArrayList();
int anonymousUser = SystemGlobals.getIntValue(ConfigKeys.ANONYMOUS_USER_ID);
for (Iterator iter = posts.iterator(); iter.hasNext(); ) {
Post p;
if (needPrepare) {
p = (Post) iter.next();
} else {
p = new Post((Post) iter.next());
}
if (canEdit || (p.getUserId() != anonymousUser && p.getUserId() == userId)) {
p.setCanEdit(true);
}
helperList.add(needPrepare ? PostCommon.preparePostForDisplay(p) : p);
}
return helperList;
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class PostRepository method remove.
public static void remove(int topicId, int postId) {
synchronized (FQN) {
String tid = Integer.toString(topicId);
List posts = (List) cache.get(FQN, tid);
if (posts != null) {
Post p = new Post();
p.setId(postId);
posts.remove(p);
cache.add(FQN, tid, posts);
}
}
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class SqlServer2000PostDAO method selectLatestByForumForRSS.
public List selectLatestByForumForRSS(int forumId, int limit) {
List l = new ArrayList();
String sql = SystemGlobals.getSql("PostModel.selectLatestByForumForRSS");
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(sql);
p.setInt(1, limit);
p.setInt(2, forumId);
rs = p.executeQuery();
while (rs.next()) {
Post post = this.buildPostForRSS(rs);
l.add(post);
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
return l;
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class SqlServer2000PostDAO method selectHotForRSS.
public List selectHotForRSS(int limit) {
List l = new ArrayList();
String sql = SystemGlobals.getSql("PostModel.selectHotForRSS");
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(sql);
p.setInt(1, limit);
rs = p.executeQuery();
while (rs.next()) {
Post post = this.buildPostForRSS(rs);
l.add(post);
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
return l;
}
Aggregations