Search in sources :

Example 26 with Forum

use of net.jforum.entities.Forum in project jforum2 by rafaelsteil.

the class ForumOrderComparator method compare.

public final int compare(Object a, Object b) {
    Forum f1 = (Forum) a;
    Forum f2 = (Forum) b;
    if (f1.getOrder() > f2.getOrder()) {
        return 1;
    } else if (f1.getOrder() < f2.getOrder()) {
        return -1;
    } else {
        return f1.getName().compareTo(f2.getName());
    }
}
Also used : Forum(net.jforum.entities.Forum)

Example 27 with Forum

use of net.jforum.entities.Forum in project jforum2 by rafaelsteil.

the class ConfigAction method updateData.

void updateData(Properties p) {
    int oldTopicsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
    for (Iterator iter = p.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry entry = (Map.Entry) iter.next();
        SystemGlobals.setValue((String) entry.getKey(), (String) entry.getValue());
    }
    SystemGlobals.saveInstallation();
    I18n.changeBoardDefault(SystemGlobals.getValue(ConfigKeys.I18N_DEFAULT));
    // If topicsPerPage has changed, force a reload in all forums
    if (oldTopicsPerPage != SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE)) {
        List categories = ForumRepository.getAllCategories();
        for (Iterator iter = categories.iterator(); iter.hasNext(); ) {
            Category c = (Category) iter.next();
            for (Iterator iter2 = c.getForums().iterator(); iter2.hasNext(); ) {
                Forum f = (Forum) iter2.next();
                TopicRepository.clearCache(f.getId());
            }
        }
    }
}
Also used : Category(net.jforum.entities.Category) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Forum(net.jforum.entities.Forum)

Example 28 with Forum

use of net.jforum.entities.Forum 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

Forum (net.jforum.entities.Forum)28 List (java.util.List)14 Iterator (java.util.Iterator)13 Map (java.util.Map)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 Topic (net.jforum.entities.Topic)8 Category (net.jforum.entities.Category)7 ForumDAO (net.jforum.dao.ForumDAO)5 TopicDAO (net.jforum.dao.TopicDAO)5 User (net.jforum.entities.User)5 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)4 PostDAO (net.jforum.dao.PostDAO)3 UserDAO (net.jforum.dao.UserDAO)3 UserSession (net.jforum.entities.UserSession)3 PermissionControl (net.jforum.security.PermissionControl)3 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Set (java.util.Set)2