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;
}
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());
}
}
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();
}
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();
}
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());
}
}
}
}
Aggregations