- on category setParent dialog do not show children of current category
- break recursion if category parentCid is equal to child cid to prevent
infinite loop
- dont allow setting the parentCid of a category to one of it's children
This commit is contained in:
Baris Usakli
2018-11-06 13:34:29 -05:00
parent 9a9f2af9c1
commit 3c611d85ed
4 changed files with 70 additions and 2 deletions

View File

@@ -92,6 +92,12 @@ module.exports = function (Categories) {
}
async.waterfall([
function (next) {
Categories.getChildrenCids(cid, next);
},
function (childrenCids, next) {
if (childrenCids.includes(parseInt(newParent, 10))) {
return next(new Error('[[error:cant-set-child-as-parent]]'));
}
Categories.getCategoryField(cid, 'parentCid', next);
},
function (oldParent, next) {