Merge pull request #3299 from NicolasSiver/category-update

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

11
.gitignore vendored

@ -8,7 +8,6 @@ public/css/*.css
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
.project .project
.idea
*.swp *.swp
Vagrantfile Vagrantfile
.vagrant .vagrant
@ -32,3 +31,13 @@ pidfile
/public/admin.css /public/admin.css
/public/nodebb.min.js /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); 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); var fields = Object.keys(category);
async.each(fields, function(key, next) { async.each(fields, function(key, next) {
updateCategoryField(cid, key, category[key], next); updateCategoryField(cid, key, category[key], next);
@ -44,10 +51,7 @@ module.exports = function(Categories) {
return callback(err); return callback(err);
} }
if (key === 'name') { if (key === 'order') {
var slug = cid + '/' + utils.slugify(value);
db.setObjectField('category:' + cid, 'slug', slug, callback);
} else if (key === 'order') {
db.sortedSetAdd('categories:cid', value, cid, callback); db.sortedSetAdd('categories:cid', value, cid, callback);
} else { } else {
callback(); callback();

Loading…
Cancel
Save