Search in sources :

Example 1 with GroupDAO

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

the class GroupAction method edit.

// Edit a group
public void edit() {
    int groupId = this.request.getIntParameter("group_id");
    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();
    this.setTemplateName(TemplateKeys.GROUP_EDIT);
    this.context.put("group", gm.selectById(groupId));
    this.context.put("groups", new TreeGroup().getNodes());
    this.context.put("selectedList", new ArrayList());
    this.context.put("action", "editSave");
}
Also used : TreeGroup(net.jforum.util.TreeGroup) ArrayList(java.util.ArrayList) GroupDAO(net.jforum.dao.GroupDAO)

Example 2 with GroupDAO

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

the class GroupAction method delete.

// Deletes a group
public void delete() {
    String[] groupId = this.request.getParameterValues("group_id");
    if (groupId == null) {
        this.list();
        return;
    }
    List errors = new ArrayList();
    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();
    for (int i = 0; i < groupId.length; i++) {
        int id = Integer.parseInt(groupId[i]);
        if (gm.canDelete(id)) {
            gm.delete(id);
        } else {
            errors.add(I18n.getMessage(I18n.CANNOT_DELETE_GROUP, new Object[] { new Integer(id) }));
        }
    }
    if (errors.size() > 0) {
        this.context.put("errorMessage", errors);
    }
    this.list();
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GroupDAO(net.jforum.dao.GroupDAO)

Example 3 with GroupDAO

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

the class GroupAction method insertSave.

// Saves a new group
public void insertSave() {
    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();
    Group g = new Group();
    g.setDescription(this.request.getParameter("group_description"));
    g.setParentId(this.request.getIntParameter("parent_id"));
    g.setName(this.request.getParameter("group_name"));
    gm.addNew(g);
    this.list();
}
Also used : TreeGroup(net.jforum.util.TreeGroup) Group(net.jforum.entities.Group) GroupDAO(net.jforum.dao.GroupDAO)

Example 4 with GroupDAO

use of net.jforum.dao.GroupDAO 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 5 with GroupDAO

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

the class GroupAction method permissions.

// Permissions
public void permissions() {
    int id = this.request.getIntParameter("group_id");
    PermissionControl pc = new PermissionControl();
    pc.setRoles(DataAccessDriver.getInstance().newGroupSecurityDAO().loadRoles(id));
    String xmlconfig = SystemGlobals.getValue(ConfigKeys.CONFIG_DIR) + "/permissions.xml";
    List sections = new XMLPermissionControl(pc).loadConfigurations(xmlconfig);
    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();
    this.context.put("sections", sections);
    this.context.put("group", gm.selectById(id));
    this.setTemplateName(TemplateKeys.GROUP_PERMISSIONS);
}
Also used : XMLPermissionControl(net.jforum.security.XMLPermissionControl) PermissionControl(net.jforum.security.PermissionControl) ArrayList(java.util.ArrayList) List(java.util.List) GroupDAO(net.jforum.dao.GroupDAO) XMLPermissionControl(net.jforum.security.XMLPermissionControl)

Aggregations

GroupDAO (net.jforum.dao.GroupDAO)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 TreeGroup (net.jforum.util.TreeGroup)3 Group (net.jforum.entities.Group)2 Iterator (java.util.Iterator)1 UserDAO (net.jforum.dao.UserDAO)1 PermissionControl (net.jforum.security.PermissionControl)1 XMLPermissionControl (net.jforum.security.XMLPermissionControl)1