Search in sources :

Example 1 with Bookmark

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);
}
Also used : Bookmark(net.jforum.entities.Bookmark) SafeHtml(net.jforum.util.SafeHtml)

Example 2 with Bookmark

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);
}
Also used : BookmarkDAO(net.jforum.dao.BookmarkDAO) Bookmark(net.jforum.entities.Bookmark)

Example 3 with Bookmark

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()));
}
Also used : Bookmark(net.jforum.entities.Bookmark) Forum(net.jforum.entities.Forum)

Example 4 with Bookmark

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()));
}
Also used : User(net.jforum.entities.User) Bookmark(net.jforum.entities.Bookmark)

Example 5 with Bookmark

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);
    }
}
Also used : Bookmark(net.jforum.entities.Bookmark) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) List(java.util.List) ArrayList(java.util.ArrayList) DatabaseException(net.jforum.exceptions.DatabaseException)

Aggregations

Bookmark (net.jforum.entities.Bookmark)14 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 SQLException (java.sql.SQLException)5 DatabaseException (net.jforum.exceptions.DatabaseException)5 List (java.util.List)4 ArrayList (java.util.ArrayList)3 BookmarkDAO (net.jforum.dao.BookmarkDAO)3 User (net.jforum.entities.User)2 Iterator (java.util.Iterator)1 DataAccessDriver (net.jforum.dao.DataAccessDriver)1 UserDAO (net.jforum.dao.UserDAO)1 Forum (net.jforum.entities.Forum)1 Topic (net.jforum.entities.Topic)1 RankingRepository (net.jforum.repository.RankingRepository)1 SafeHtml (net.jforum.util.SafeHtml)1