Search in sources :

Example 1 with BanlistDAO

use of net.jforum.dao.BanlistDAO in project jforum2 by rafaelsteil.

the class BanlistRepository method loadBanlist.

public static void loadBanlist() {
    BanlistDAO dao = DataAccessDriver.getInstance().newBanlistDAO();
    List banlist = dao.selectAll();
    for (Iterator iter = banlist.iterator(); iter.hasNext(); ) {
        BanlistRepository.add((Banlist) iter.next());
    }
}
Also used : BanlistDAO(net.jforum.dao.BanlistDAO) Iterator(java.util.Iterator) List(java.util.List)

Example 2 with BanlistDAO

use of net.jforum.dao.BanlistDAO in project jforum2 by rafaelsteil.

the class BanlistAction method delete.

public void delete() {
    String[] banlist = this.request.getParameterValues("banlist_id");
    if (banlist != null && banlist.length > 0) {
        BanlistDAO dao = DataAccessDriver.getInstance().newBanlistDAO();
        for (int i = 0; i < banlist.length; i++) {
            int current = Integer.parseInt(banlist[i]);
            dao.delete(current);
            BanlistRepository.remove(current);
        }
    }
    this.list();
}
Also used : BanlistDAO(net.jforum.dao.BanlistDAO)

Example 3 with BanlistDAO

use of net.jforum.dao.BanlistDAO in project jforum2 by rafaelsteil.

the class BanlistAction method insertSave.

public void insertSave() {
    String type = this.request.getParameter("type");
    String value = this.request.getParameter("value");
    if (!StringUtils.isEmpty(type) && !StringUtils.isEmpty(value)) {
        Banlist b = new Banlist();
        if ("email".equals(type)) {
            b.setEmail(value);
        } else if ("user".equals(type)) {
            b.setUserId(Integer.parseInt(value));
        } else if ("ip".equals(type)) {
            b.setIp(value);
        } else {
            throw new ForumException("Unknown banlist type");
        }
        BanlistDAO dao = DataAccessDriver.getInstance().newBanlistDAO();
        dao.insert(b);
        BanlistRepository.add(b);
    }
    this.list();
}
Also used : ForumException(net.jforum.exceptions.ForumException) BanlistDAO(net.jforum.dao.BanlistDAO) Banlist(net.jforum.entities.Banlist)

Aggregations

BanlistDAO (net.jforum.dao.BanlistDAO)3 Iterator (java.util.Iterator)1 List (java.util.List)1 Banlist (net.jforum.entities.Banlist)1 ForumException (net.jforum.exceptions.ForumException)1