use of net.jforum.entities.Group in project jforum2 by rafaelsteil.
the class UserAction method groupsSave.
// Groups Save
public void groupsSave() {
int userId = this.request.getIntParameter("user_id");
UserDAO um = DataAccessDriver.getInstance().newUserDAO();
GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();
// Remove the old groups
List allGroupsList = gm.selectAll();
int[] allGroups = new int[allGroupsList.size()];
int counter = 0;
for (Iterator iter = allGroupsList.iterator(); iter.hasNext(); counter++) {
Group g = (Group) iter.next();
allGroups[counter] = g.getId();
}
um.removeFromGroup(userId, allGroups);
// Associate the user to the selected groups
String[] selectedGroups = this.request.getParameterValues("groups");
if (selectedGroups == null) {
selectedGroups = new String[0];
}
int[] newGroups = new int[selectedGroups.length];
for (int i = 0; i < selectedGroups.length; i++) {
newGroups[i] = Integer.parseInt(selectedGroups[i]);
}
um.addToGroup(userId, newGroups);
SecurityRepository.remove(userId);
this.list();
}
use of net.jforum.entities.Group in project jforum2 by rafaelsteil.
the class GenericGroupDAO method getGroup.
protected Group getGroup(ResultSet rs) throws SQLException {
Group g = new Group();
g.setId(rs.getInt("group_id"));
g.setDescription(rs.getString("group_description"));
g.setName(rs.getString("group_name"));
g.setParentId(rs.getInt("parent_id"));
return g;
}
Aggregations