use of net.jforum.security.PermissionControl in project jforum2 by rafaelsteil.
the class ForumAction method insertSave.
// A new one
public void insertSave() {
Forum f = new Forum();
f.setDescription(this.request.getParameter("description"));
f.setIdCategories(this.request.getIntParameter("categories_id"));
f.setName(this.request.getParameter("forum_name"));
f.setModerated("1".equals(this.request.getParameter("moderate")));
int forumId = DataAccessDriver.getInstance().newForumDAO().addNew(f);
f.setId(forumId);
ForumRepository.addForum(f);
GroupSecurityDAO gmodel = DataAccessDriver.getInstance().newGroupSecurityDAO();
PermissionControl pc = new PermissionControl();
pc.setSecurityModel(gmodel);
String[] allGroups = this.request.getParameterValues("groups");
// Access
String[] groups = this.request.getParameterValues("groupsAccess");
if (groups != null) {
this.addRole(pc, SecurityConstants.PERM_FORUM, f.getId(), groups);
} else {
this.addRole(pc, SecurityConstants.PERM_FORUM, f.getId(), allGroups);
}
// Anonymous posts
groups = this.request.getParameterValues("groupsAnonymous");
if (groups != null) {
this.addRole(pc, SecurityConstants.PERM_ANONYMOUS_POST, f.getId(), groups);
} else {
this.addRole(pc, SecurityConstants.PERM_ANONYMOUS_POST, f.getId(), allGroups);
}
// Read-only
groups = this.request.getParameterValues("groupsReadOnly");
if (groups != null) {
this.addRole(pc, SecurityConstants.PERM_READ_ONLY_FORUMS, f.getId(), groups);
} else {
this.addRole(pc, SecurityConstants.PERM_READ_ONLY_FORUMS, f.getId(), allGroups);
}
// Reply-only
this.addRole(pc, SecurityConstants.PERM_REPLY_ONLY, f.getId(), allGroups);
// HTML
groups = this.request.getParameterValues("groupsHtml");
if (groups != null) {
this.addRole(pc, SecurityConstants.PERM_HTML_DISABLED, f.getId(), groups);
} else {
this.addRole(pc, SecurityConstants.PERM_HTML_DISABLED, f.getId(), allGroups);
}
SecurityRepository.clean();
RolesRepository.clear();
// this.handleMailIntegration();
this.list();
}
Aggregations