mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
closes #5779
This commit is contained in:
@@ -19,7 +19,7 @@ module.exports = function (Categories) {
|
|||||||
}, { alwaysStartAt: 0 }, next);
|
}, { alwaysStartAt: 0 }, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
Categories.getPinnedTids('cid:' + cid + ':tids:pinned', 0, -1, next);
|
db.getSortedSetRevRange('cid:' + cid + ':tids:pinned', 0, -1, next);
|
||||||
},
|
},
|
||||||
function (pinnedTids, next) {
|
function (pinnedTids, next) {
|
||||||
async.eachLimit(pinnedTids, 10, function (tid, next) {
|
async.eachLimit(pinnedTids, 10, function (tid, next) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
var db = require('../database');
|
var db = require('../database');
|
||||||
var topics = require('../topics');
|
var topics = require('../topics');
|
||||||
@@ -41,7 +42,10 @@ module.exports = function (Categories) {
|
|||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
Categories.getPinnedTids(data.cid, 0, -1, next);
|
var dataForPinned = _.cloneDeep(data);
|
||||||
|
dataForPinned.start = 0;
|
||||||
|
dataForPinned.stop = -1;
|
||||||
|
Categories.getPinnedTids(dataForPinned, next);
|
||||||
},
|
},
|
||||||
function (_pinnedTids, next) {
|
function (_pinnedTids, next) {
|
||||||
var totalPinnedCount = _pinnedTids.length;
|
var totalPinnedCount = _pinnedTids.length;
|
||||||
@@ -148,8 +152,17 @@ module.exports = function (Categories) {
|
|||||||
db.getSortedSetRange(['cid:' + cid + ':tids:pinned', 'cid:' + cid + ':tids'], start, stop, callback);
|
db.getSortedSetRange(['cid:' + cid + ':tids:pinned', 'cid:' + cid + ':tids'], start, stop, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Categories.getPinnedTids = function (cid, start, stop, callback) {
|
Categories.getPinnedTids = function (data, callback) {
|
||||||
db.getSortedSetRevRange('cid:' + cid + ':tids:pinned', start, stop, callback);
|
if (plugins.hasListeners('filter:categories.getPinnedTids')) {
|
||||||
|
return plugins.fireHook('filter:categories.getPinnedTids', {
|
||||||
|
pinnedTids: [],
|
||||||
|
data: data,
|
||||||
|
}, function (err, data) {
|
||||||
|
callback(err, data && data.pinnedTids);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
db.getSortedSetRevRange('cid:' + data.cid + ':tids:pinned', data.start, data.stop, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Categories.modifyTopicsByPrivilege = function (topics, privileges) {
|
Categories.modifyTopicsByPrivilege = function (topics, privileges) {
|
||||||
|
|||||||
@@ -154,16 +154,13 @@ module.exports = function (Topics) {
|
|||||||
var topicData;
|
var topicData;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
Topics.exists(tid, next);
|
Topics.getTopicData(tid, next);
|
||||||
},
|
|
||||||
function (exists, next) {
|
|
||||||
if (!exists) {
|
|
||||||
return callback(new Error('[[error:no-topic]]'));
|
|
||||||
}
|
|
||||||
Topics.getTopicFields(tid, ['uid', 'tid', 'cid', 'lastposttime', 'postcount'], next);
|
|
||||||
},
|
},
|
||||||
function (_topicData, next) {
|
function (_topicData, next) {
|
||||||
topicData = _topicData;
|
topicData = _topicData;
|
||||||
|
if (!topicData) {
|
||||||
|
return callback(new Error('[[error:no-topic]]'));
|
||||||
|
}
|
||||||
privileges.categories.isAdminOrMod(_topicData.cid, uid, next);
|
privileges.categories.isAdminOrMod(_topicData.cid, uid, next);
|
||||||
},
|
},
|
||||||
function (isAdminOrMod, next) {
|
function (isAdminOrMod, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user