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");
}
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();
}
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();
}
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();
}
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);
}
Aggregations