Search in sources :

Example 6 with Group

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();
}
Also used : TreeGroup(net.jforum.util.TreeGroup) Group(net.jforum.entities.Group) UserDAO(net.jforum.dao.UserDAO) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) GroupDAO(net.jforum.dao.GroupDAO)

Example 7 with Group

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

Aggregations

Group (net.jforum.entities.Group)7 TreeGroup (net.jforum.util.TreeGroup)4 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 GroupDAO (net.jforum.dao.GroupDAO)2 UserDAO (net.jforum.dao.UserDAO)2 User (net.jforum.entities.User)2 DatabaseException (net.jforum.exceptions.DatabaseException)2