use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class BookmarkAction method insertSave.
public void insertSave() {
SafeHtml safeHtml = new SafeHtml();
Bookmark b = new Bookmark();
b.setDescription(safeHtml.makeSafe(this.request.getParameter("description")));
b.setTitle(safeHtml.makeSafe(this.request.getParameter("title")));
String publicVisible = this.request.getParameter("visible");
b.setPublicVisible(publicVisible != null && publicVisible.length() > 0);
b.setRelationId(this.request.getIntParameter("relation_id"));
b.setRelationType(this.request.getIntParameter("relation_type"));
b.setUserId(SessionFacade.getUserSession().getUserId());
DataAccessDriver.getInstance().newBookmarkDAO().add(b);
this.setTemplateName(TemplateKeys.BOOKMARKS_INSERT_SAVE);
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class BookmarkAction method edit.
public void edit() {
int id = this.request.getIntParameter("bookmark_id");
BookmarkDAO bm = DataAccessDriver.getInstance().newBookmarkDAO();
Bookmark b = bm.selectById(id);
if (!this.sanityCheck(b)) {
return;
}
this.setTemplateName(TemplateKeys.BOOKMARKS_EDIT);
this.context.put("bookmark", b);
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class BookmarkAction method addForum.
private void addForum() {
Forum f = ForumRepository.getForum(this.request.getIntParameter("relation_id"));
String title = f.getName();
String description = f.getDescription();
Bookmark b = DataAccessDriver.getInstance().newBookmarkDAO().selectForUpdate(f.getId(), BookmarkType.FORUM, SessionFacade.getUserSession().getUserId());
if (b != null) {
if (b.getTitle() != null) {
title = b.getTitle();
}
if (b.getDescription() != null) {
description = b.getDescription();
}
this.context.put("bookmark", b);
}
this.setTemplateName(TemplateKeys.BOOKMARKS_ADD_FORUM);
this.context.put("title", title);
this.context.put("description", description);
this.context.put("relationType", new Integer(BookmarkType.FORUM));
this.context.put("relationId", new Integer(f.getId()));
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class BookmarkAction method addUser.
private void addUser() {
User u = DataAccessDriver.getInstance().newUserDAO().selectById(this.request.getIntParameter("relation_id"));
String title = u.getUsername();
Bookmark b = DataAccessDriver.getInstance().newBookmarkDAO().selectForUpdate(u.getId(), BookmarkType.USER, SessionFacade.getUserSession().getUserId());
if (b != null) {
if (b.getTitle() != null) {
title = b.getTitle();
}
this.context.put("description", b.getDescription());
this.context.put("bookmark", b);
}
this.setTemplateName(TemplateKeys.BOOKMARKS_ADD_USER);
this.context.put("title", title);
this.context.put("relationType", new Integer(BookmarkType.USER));
this.context.put("relationId", new Integer(u.getId()));
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method getForums.
protected List getForums(int userId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
List l = new ArrayList();
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectForumBookmarks"));
p.setInt(1, userId);
rs = p.executeQuery();
while (rs.next()) {
Bookmark b = this.getBookmark(rs);
if (b.getTitle() == null || "".equals(b.getTitle())) {
b.setTitle(rs.getString("forum_name"));
}
if (b.getDescription() == null || "".equals(b.getDescription())) {
b.setDescription(rs.getString("forum_desc"));
}
l.add(b);
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations