mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 11:11:04 +01:00
if no order is specified during a category creation, NodeBB won't crash
This commit is contained in:
@@ -13,7 +13,8 @@ module.exports = function(Categories) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var slug = cid + '/' + utils.slugify(data.name);
|
||||
var slug = cid + '/' + utils.slugify(data.name),
|
||||
order = data.order || cid; // If no order provided, place it at the end
|
||||
|
||||
var category = {
|
||||
cid: cid,
|
||||
@@ -27,7 +28,7 @@ module.exports = function(Categories) {
|
||||
topic_count: 0,
|
||||
post_count: 0,
|
||||
disabled: 0,
|
||||
order: data.order,
|
||||
order: order,
|
||||
link: '',
|
||||
numRecentReplies: 1,
|
||||
class: 'col-md-3 col-xs-6',
|
||||
@@ -38,7 +39,7 @@ module.exports = function(Categories) {
|
||||
|
||||
async.series([
|
||||
async.apply(db.setObject, 'category:' + cid, category),
|
||||
async.apply(db.sortedSetAdd, 'categories:cid', data.order, cid),
|
||||
async.apply(db.sortedSetAdd, 'categories:cid', order, cid),
|
||||
async.apply(privileges.categories.give, defaultPrivileges, cid, 'administrators'),
|
||||
async.apply(privileges.categories.give, defaultPrivileges, cid, 'registered-users'),
|
||||
async.apply(privileges.categories.give, ['find', 'read'], cid, 'guests')
|
||||
|
||||
Reference in New Issue
Block a user