Search in sources :

Example 16 with Category

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

the class GenericCategoryDAO method getCategory.

protected Category getCategory(ResultSet rs) throws SQLException {
    Category c = new Category();
    c.setId(rs.getInt("categories_id"));
    c.setName(rs.getString("title"));
    c.setOrder(rs.getInt("display_order"));
    c.setModerated(rs.getInt("moderated") == 1);
    return c;
}
Also used : Category(net.jforum.entities.Category)

Example 17 with Category

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

the class CategoryOrderComparator method compare.

/** 
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
public int compare(Object o1, Object o2) {
    Category c1 = (Category) o1;
    Category c2 = (Category) o2;
    if (c1.getOrder() > c2.getOrder()) {
        return 1;
    } else if (c1.getOrder() < c2.getOrder()) {
        return -1;
    } else {
        return c1.getName().compareTo(c2.getName());
    }
}
Also used : Category(net.jforum.entities.Category)

Example 18 with Category

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

the class CategoryAction method delete.

// Delete
public void delete() {
    String[] ids = this.request.getParameterValues("categories_id");
    List errors = new ArrayList();
    if (ids != null) {
        for (int i = 0; i < ids.length; i++) {
            if (this.cm.canDelete(Integer.parseInt(ids[i]))) {
                int id = Integer.parseInt(ids[i]);
                Category c = this.cm.selectById(id);
                this.cm.delete(id);
                ForumRepository.removeCategory(c);
            } else {
                errors.add(I18n.getMessage(I18n.CANNOT_DELETE_CATEGORY, new Object[] { new Integer(ids[i]) }));
            }
        }
    }
    if (errors.size() > 0) {
        this.context.put("errorMessage", errors);
    }
    this.list();
}
Also used : Category(net.jforum.entities.Category) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 19 with Category

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

the class CategoryAction method insertSave.

// A new one
public void insertSave() {
    Category c = new Category();
    c.setName(this.request.getParameter("category_name"));
    c.setModerated("1".equals(this.request.getParameter("moderated")));
    int categoryId = this.cm.addNew(c);
    c.setId(categoryId);
    ForumRepository.addCategory(c);
    String[] groups = this.request.getParameterValues("groups");
    if (groups != null) {
        GroupSecurityDAO gmodel = DataAccessDriver.getInstance().newGroupSecurityDAO();
        PermissionControl pc = new PermissionControl();
        pc.setSecurityModel(gmodel);
        Role role = new Role();
        role.setName(SecurityConstants.PERM_CATEGORY);
        for (int i = 0; i < groups.length; i++) {
            int groupId = Integer.parseInt(groups[i]);
            RoleValueCollection roleValues = new RoleValueCollection();
            RoleValue rv = new RoleValue();
            rv.setValue(Integer.toString(categoryId));
            roleValues.add(rv);
            pc.addRoleValue(groupId, role, roleValues);
        }
        SecurityRepository.clean();
        RolesRepository.clear();
    }
    this.list();
}
Also used : Role(net.jforum.security.Role) Category(net.jforum.entities.Category) PermissionControl(net.jforum.security.PermissionControl) RoleValue(net.jforum.security.RoleValue) RoleValueCollection(net.jforum.security.RoleValueCollection) GroupSecurityDAO(net.jforum.dao.GroupSecurityDAO)

Example 20 with Category

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

Aggregations

Category (net.jforum.entities.Category)20 ArrayList (java.util.ArrayList)9 List (java.util.List)9 Forum (net.jforum.entities.Forum)7 Iterator (java.util.Iterator)6 Map (java.util.Map)6 Set (java.util.Set)6 TreeSet (java.util.TreeSet)6 HashMap (java.util.HashMap)5 CategoryNotFoundException (net.jforum.exceptions.CategoryNotFoundException)2 DatabaseException (net.jforum.exceptions.DatabaseException)2 PermissionControl (net.jforum.security.PermissionControl)2 CategoryOrderComparator (net.jforum.util.CategoryOrderComparator)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 ForumDAO (net.jforum.dao.ForumDAO)1 GroupSecurityDAO (net.jforum.dao.GroupSecurityDAO)1