v1.18.x
barisusakli 9 years ago
parent b6e22b7723
commit c9cfe5b089

@ -53,7 +53,7 @@
"nodebb-plugin-spam-be-gone": "0.4.5", "nodebb-plugin-spam-be-gone": "0.4.5",
"nodebb-rewards-essentials": "0.0.8", "nodebb-rewards-essentials": "0.0.8",
"nodebb-theme-lavender": "3.0.9", "nodebb-theme-lavender": "3.0.9",
"nodebb-theme-persona": "4.0.93", "nodebb-theme-persona": "4.0.94",
"nodebb-theme-vanilla": "5.0.54", "nodebb-theme-vanilla": "5.0.54",
"nodebb-widget-essentials": "2.0.8", "nodebb-widget-essentials": "2.0.8",
"nodemailer": "2.0.0", "nodemailer": "2.0.0",

@ -113,7 +113,7 @@
'<i style="color:' + child.color + ';" class="fa fa-stack-1x ' + child.icon + '"></i>' + '<i style="color:' + child.color + ';" class="fa fa-stack-1x ' + child.icon + '"></i>' +
'</span><small>' + child.name + '</small></a> '; '</span><small>' + child.name + '</small></a> ';
}); });
html = html ? ('<br/><span class="category-children">' + html + '</span>') : html; html = html ? ('<span class="category-children">' + html + '</span>') : html;
return html; return html;
}; };

@ -17,15 +17,15 @@ module.exports = function(Categories) {
db.incrObjectField('global', 'nextCid', next); db.incrObjectField('global', 'nextCid', next);
}, },
function(cid, next) { function(cid, next) {
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 order = data.order || cid; // If no order provided, place it at the end
colours = Categories.assignColours(); var colours = Categories.assignColours();
category = { category = {
cid: cid, cid: cid,
name: data.name, name: data.name,
description: ( data.description ? data.description : '' ), description: data.description ? data.description : '',
icon: ( data.icon ? data.icon : '' ), icon: data.icon ? data.icon : '',
bgColor: data.bgColor || colours[0], bgColor: data.bgColor || colours[0],
color: data.color || colours[1], color: data.color || colours[1],
slug: slug, slug: slug,
@ -49,6 +49,7 @@ module.exports = function(Categories) {
async.series([ async.series([
async.apply(db.setObject, 'category:' + category.cid, category), async.apply(db.setObject, 'category:' + category.cid, category),
async.apply(Categories.parseDescription, category.cid, category.description),
async.apply(db.sortedSetAdd, 'categories:cid', category.order, category.cid), async.apply(db.sortedSetAdd, 'categories:cid', category.order, category.cid),
async.apply(db.sortedSetAdd, 'cid:' + parentCid + ':children', category.order, category.cid), async.apply(db.sortedSetAdd, 'cid:' + parentCid + ':children', category.order, category.cid),
async.apply(privileges.categories.give, defaultPrivileges, category.cid, 'administrators'), async.apply(privileges.categories.give, defaultPrivileges, category.cid, 'administrators'),

@ -72,7 +72,7 @@ module.exports = function(Categories) {
if (key === 'order') { if (key === 'order') {
updateOrder(cid, value, callback); updateOrder(cid, value, callback);
} else if (key === 'description') { } else if (key === 'description') {
parseDescription(cid, value, callback); Categories.parseDescription(cid, value, callback);
} else { } else {
callback(); callback();
} }
@ -100,7 +100,7 @@ module.exports = function(Categories) {
function (next) { function (next) {
db.setObjectField('category:' + cid, 'parentCid', newParent, next); db.setObjectField('category:' + cid, 'parentCid', newParent, next);
} }
], function(err, results) { ], function(err) {
callback(err); callback(err);
}); });
}); });
@ -124,13 +124,13 @@ module.exports = function(Categories) {
}); });
} }
function parseDescription(cid, description, callback) { Categories.parseDescription = function(cid, description, callback) {
plugins.fireHook('filter:parse.raw', description, function(err, parsedDescription) { plugins.fireHook('filter:parse.raw', description, function(err, parsedDescription) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
Categories.setCategoryField(cid, 'descriptionParsed', parsedDescription, callback); Categories.setCategoryField(cid, 'descriptionParsed', parsedDescription, callback);
}); });
} };
}; };

Loading…
Cancel
Save