|
|
@ -76,27 +76,7 @@ modsController.flags.list = function (req, res, next) {
|
|
|
|
}, next);
|
|
|
|
}, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (data) {
|
|
|
|
function (data) {
|
|
|
|
// If res.locals.cids is populated, then slim down the categories list
|
|
|
|
data.categories = filterCategories(res.locals.cids, data.categories);
|
|
|
|
if (res.locals.cids) {
|
|
|
|
|
|
|
|
data.categories = data.categories.filter(function (category) {
|
|
|
|
|
|
|
|
return res.locals.cids.indexOf(String(category.cid)) !== -1;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Minimal returned set for templates.js
|
|
|
|
|
|
|
|
data.categories = data.categories.reduce(function (memo, cur) {
|
|
|
|
|
|
|
|
if (!res.locals.cids) {
|
|
|
|
|
|
|
|
memo[cur.cid] = cur.name;
|
|
|
|
|
|
|
|
return memo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If mod, remove categories they can't moderate
|
|
|
|
|
|
|
|
if (res.locals.cids.indexOf(String(cur.cid)) !== -1) {
|
|
|
|
|
|
|
|
memo[cur.cid] = cur.name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return memo;
|
|
|
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.render('flags/list', {
|
|
|
|
res.render('flags/list', {
|
|
|
|
flags: data.flags.flags,
|
|
|
|
flags: data.flags.flags,
|
|
|
@ -117,6 +97,7 @@ modsController.flags.detail = function (req, res, next) {
|
|
|
|
moderatedCids: async.apply(user.getModeratedCids, req.uid),
|
|
|
|
moderatedCids: async.apply(user.getModeratedCids, req.uid),
|
|
|
|
flagData: async.apply(flags.get, req.params.flagId),
|
|
|
|
flagData: async.apply(flags.get, req.params.flagId),
|
|
|
|
assignees: async.apply(user.getAdminsandGlobalModsandModerators),
|
|
|
|
assignees: async.apply(user.getAdminsandGlobalModsandModerators),
|
|
|
|
|
|
|
|
categories: async.apply(categories.buildForSelect, req.uid, 'read'),
|
|
|
|
}, function (err, results) {
|
|
|
|
}, function (err, results) {
|
|
|
|
if (err || !results.flagData) {
|
|
|
|
if (err || !results.flagData) {
|
|
|
|
return next(err || new Error('[[error:invalid-data]]'));
|
|
|
|
return next(err || new Error('[[error:invalid-data]]'));
|
|
|
@ -124,6 +105,12 @@ modsController.flags.detail = function (req, res, next) {
|
|
|
|
return next(new Error('[[error:no-privileges]]'));
|
|
|
|
return next(new Error('[[error:no-privileges]]'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!results.isAdminOrGlobalMod && results.moderatedCids.length) {
|
|
|
|
|
|
|
|
res.locals.cids = results.moderatedCids;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results.categories = filterCategories(res.locals.cids, results.categories);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.flagData.type === 'user') {
|
|
|
|
if (results.flagData.type === 'user') {
|
|
|
|
results.flagData.type_path = 'uid';
|
|
|
|
results.flagData.type_path = 'uid';
|
|
|
|
} else if (results.flagData.type === 'post') {
|
|
|
|
} else if (results.flagData.type === 'post') {
|
|
|
@ -142,10 +129,34 @@ modsController.flags.detail = function (req, res, next) {
|
|
|
|
return memo;
|
|
|
|
return memo;
|
|
|
|
}, {}),
|
|
|
|
}, {}),
|
|
|
|
title: '[[pages:flag-details, ' + req.params.flagId + ']]',
|
|
|
|
title: '[[pages:flag-details, ' + req.params.flagId + ']]',
|
|
|
|
|
|
|
|
categories: results.categories,
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function filterCategories(moderatedCids, categories) {
|
|
|
|
|
|
|
|
// If cids is populated, then slim down the categories list
|
|
|
|
|
|
|
|
if (moderatedCids) {
|
|
|
|
|
|
|
|
categories = categories.filter(function (category) {
|
|
|
|
|
|
|
|
return moderatedCids.includes(String(category.cid));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return categories.reduce(function (memo, cur) {
|
|
|
|
|
|
|
|
if (!moderatedCids) {
|
|
|
|
|
|
|
|
memo[cur.cid] = cur.name;
|
|
|
|
|
|
|
|
return memo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If mod, remove categories they can't moderate
|
|
|
|
|
|
|
|
if (moderatedCids.includes(String(cur.cid))) {
|
|
|
|
|
|
|
|
memo[cur.cid] = cur.name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return memo;
|
|
|
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
modsController.postQueue = function (req, res, next) {
|
|
|
|
modsController.postQueue = function (req, res, next) {
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|