Merge pull request #3299 from NicolasSiver/category-update

Filter: Category update
v1.18.x
Barış Soner Uşaklı 10 years ago
commit d00e08a8e6

13
.gitignore vendored

@ -8,7 +8,6 @@ public/css/*.css
*.sublime-project
*.sublime-workspace
.project
.idea
*.swp
Vagrantfile
.vagrant
@ -31,4 +30,14 @@ pidfile
/public/stylesheet.css
/public/admin.css
/public/nodebb.min.js
/public/nodebb.min.js.map
/public/nodebb.min.js.map
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
*.iml
## Directory-based project format:
.idea/
## File-based project format:
*.ipr
*.iws

@ -16,7 +16,14 @@ module.exports = function(Categories) {
return next(err);
}
plugins.fireHook('filter:category.update', modified[cid], function(err, category) {
var modifiedFields = modified[cid];
if(modifiedFields.hasOwnProperty('name')){
modifiedFields.slug = cid + '/' + utils.slugify(modifiedFields.name);
}
plugins.fireHook('filter:category.update', {category:modifiedFields}, function(err, categoryData) {
var category = categoryData.category;
var fields = Object.keys(category);
async.each(fields, function(key, next) {
updateCategoryField(cid, key, category[key], next);
@ -44,10 +51,7 @@ module.exports = function(Categories) {
return callback(err);
}
if (key === 'name') {
var slug = cid + '/' + utils.slugify(value);
db.setObjectField('category:' + cid, 'slug', slug, callback);
} else if (key === 'order') {
if (key === 'order') {
db.sortedSetAdd('categories:cid', value, cid, callback);
} else {
callback();

Loading…
Cancel
Save