use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class BookmarkAction method addTopic.
private void addTopic() {
Topic t = DataAccessDriver.getInstance().newTopicDAO().selectById(this.request.getIntParameter("relation_id"));
String title = t.getTitle();
Bookmark b = DataAccessDriver.getInstance().newBookmarkDAO().selectForUpdate(t.getId(), BookmarkType.TOPIC, 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.BOOKMARS_ADD_TOPIC);
this.context.put("title", title);
this.context.put("relationType", new Integer(BookmarkType.TOPIC));
this.context.put("relationId", new Integer(t.getId()));
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class BookmarkAction method updateSave.
public void updateSave() {
int id = this.request.getIntParameter("bookmark_id");
BookmarkDAO bm = DataAccessDriver.getInstance().newBookmarkDAO();
Bookmark b = bm.selectById(id);
if (!this.sanityCheck(b)) {
return;
}
b.setTitle(this.request.getParameter("title"));
b.setDescription(this.request.getParameter("description"));
String visible = this.request.getParameter("visible");
b.setPublicVisible(StringUtils.isNotBlank(visible));
bm.update(b);
this.setTemplateName(TemplateKeys.BOOKMARKS_UPDATE_SAVE);
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class UserAction method profile.
public void profile() {
DataAccessDriver da = DataAccessDriver.getInstance();
UserDAO udao = da.newUserDAO();
User u = udao.selectById(this.request.getIntParameter("user_id"));
if (u.getId() == 0) {
this.userNotFound();
} else {
this.setTemplateName(TemplateKeys.USER_PROFILE);
this.context.put("karmaEnabled", SecurityRepository.canAccess(SecurityConstants.PERM_KARMA_ENABLED));
this.context.put("rank", new RankingRepository());
this.context.put("u", u);
this.context.put("avatarAllowExternalUrl", SystemGlobals.getBoolValue(ConfigKeys.AVATAR_ALLOW_EXTERNAL_URL));
int loggedId = SessionFacade.getUserSession().getUserId();
int count = 0;
List bookmarks = da.newBookmarkDAO().selectByUser(u.getId());
for (Iterator iter = bookmarks.iterator(); iter.hasNext(); ) {
Bookmark b = (Bookmark) iter.next();
if (b.isPublicVisible() || loggedId == u.getId()) {
count++;
}
}
this.context.put("pageTitle", I18n.getMessage("UserProfile.allAbout") + " " + u.getUsername());
this.context.put("nbookmarks", new Integer(count));
this.context.put("ntopics", new Integer(da.newTopicDAO().countUserTopics(u.getId())));
this.context.put("nposts", new Integer(da.newPostDAO().countUserPosts(u.getId())));
}
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method selectForUpdate.
/**
* @see net.jforum.dao.BookmarkDAO#selectForUpdate(int, int, int)
*/
public Bookmark selectForUpdate(int relationId, int relationType, int userId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectForUpdate"));
p.setInt(1, relationId);
p.setInt(2, relationType);
p.setInt(3, userId);
Bookmark b = null;
rs = p.executeQuery();
if (rs.next()) {
b = this.getBookmark(rs);
}
return b;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations