Search in sources :

Example 6 with GroupSecurityDAO

use of net.jforum.dao.GroupSecurityDAO 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();
}
Also used : PermissionControl(net.jforum.security.PermissionControl) Forum(net.jforum.entities.Forum) GroupSecurityDAO(net.jforum.dao.GroupSecurityDAO)

Aggregations

GroupSecurityDAO (net.jforum.dao.GroupSecurityDAO)6 PermissionControl (net.jforum.security.PermissionControl)4 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 DatabaseException (net.jforum.exceptions.DatabaseException)2 Category (net.jforum.entities.Category)1 Forum (net.jforum.entities.Forum)1 Role (net.jforum.security.Role)1 RoleValue (net.jforum.security.RoleValue)1 RoleValueCollection (net.jforum.security.RoleValueCollection)1 XMLPermissionControl (net.jforum.security.XMLPermissionControl)1