use of net.jforum.entities.Banlist in project jforum2 by rafaelsteil.
the class JForum method shouldBan.
private boolean shouldBan(String ip) {
Banlist b = new Banlist();
b.setUserId(SessionFacade.getUserSession().getUserId());
b.setIp(ip);
return BanlistRepository.shouldBan(b);
}
use of net.jforum.entities.Banlist 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();
}
use of net.jforum.entities.Banlist in project jforum2 by rafaelsteil.
the class GenericBanlistDAO method selectAll.
/**
* @see net.jforum.dao.BanlistDAO#selectAll()
*/
public List selectAll() {
ResultSet rs = null;
PreparedStatement p = null;
List l = new ArrayList();
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BanlistModel.selectAll"));
rs = p.executeQuery();
while (rs.next()) {
Banlist b = new Banlist();
b.setId(rs.getInt("banlist_id"));
b.setUserId(rs.getInt("user_id"));
b.setEmail(rs.getString("banlist_email"));
b.setIp(rs.getString("banlist_ip"));
l.add(b);
}
} catch (Exception e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
return l;
}
Aggregations