Search in sources :

Example 11 with PermissionControl

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

Aggregations

PermissionControl (net.jforum.security.PermissionControl)11 List (java.util.List)4 GroupSecurityDAO (net.jforum.dao.GroupSecurityDAO)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 Forum (net.jforum.entities.Forum)3 UserSession (net.jforum.entities.UserSession)3 PollDAO (net.jforum.dao.PollDAO)2 PostDAO (net.jforum.dao.PostDAO)2 TopicDAO (net.jforum.dao.TopicDAO)2 Category (net.jforum.entities.Category)2 Poll (net.jforum.entities.Poll)2 Topic (net.jforum.entities.Topic)2 XMLPermissionControl (net.jforum.security.XMLPermissionControl)2 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)2 SimpleHash (freemarker.template.SimpleHash)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1