mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
return privileges in category
This commit is contained in:
@@ -225,11 +225,13 @@ define(['composer', 'forum/pagination', 'share', 'navigator'], function(composer
|
||||
});
|
||||
}
|
||||
|
||||
Category.onTopicsLoaded = function(topics, callback) {
|
||||
if(!topics || !topics.length) {
|
||||
Category.onTopicsLoaded = function(data, callback) {
|
||||
if(!data || !data.topics.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var topics = data.topics;
|
||||
|
||||
function removeAlreadyAddedTopics() {
|
||||
topics = topics.filter(function(topic) {
|
||||
return $('#topics-container li[data-tid="' + topic.tid +'"]').length === 0;
|
||||
@@ -261,7 +263,7 @@ define(['composer', 'forum/pagination', 'share', 'navigator'], function(composer
|
||||
findInsertionPoint();
|
||||
|
||||
ajaxify.loadTemplate('category', function(categoryTemplate) {
|
||||
var html = templates.parse(templates.getBlock(categoryTemplate, 'topics'), {topics: topics});
|
||||
var html = templates.parse(templates.getBlock(categoryTemplate, 'topics'), data);
|
||||
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
var container = $('#topics-container'),
|
||||
@@ -309,6 +311,7 @@ define(['composer', 'forum/pagination', 'share', 'navigator'], function(composer
|
||||
cid: cid,
|
||||
after: after
|
||||
}, function (err, data) {
|
||||
console.log(data);
|
||||
loadingMoreTopics = false;
|
||||
|
||||
if(err) {
|
||||
@@ -316,7 +319,7 @@ define(['composer', 'forum/pagination', 'share', 'navigator'], function(composer
|
||||
}
|
||||
|
||||
if (data && data.topics.length) {
|
||||
Category.onTopicsLoaded(data.topics, callback);
|
||||
Category.onTopicsLoaded(data, callback);
|
||||
$('#topics-container').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
|
||||
|
||||
@@ -68,15 +68,15 @@ categoriesController.get = function(req, res, next) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
categoryTools.privileges(cid, uid, function(err, categoryPrivileges) {
|
||||
if (!err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!categoryPrivileges.read) {
|
||||
next(new Error('[[error:no-privileges]]'));
|
||||
} else {
|
||||
next(null, categoryPrivileges);
|
||||
}
|
||||
} else {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
function (privileges, next) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var categories = require('../categories'),
|
||||
var async = require('async'),
|
||||
categories = require('../categories'),
|
||||
categoryTools = require('../categoryTools'),
|
||||
meta = require('./../meta'),
|
||||
user = require('./../user'),
|
||||
@@ -30,12 +31,29 @@ SocketCategories.loadMore = function(socket, data, callback) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
user.getSettings(socket.uid, function(err, settings) {
|
||||
async.parallel({
|
||||
privileges: function(next) {
|
||||
categoryTools.privileges(data.cid, socket.uid, next);
|
||||
},
|
||||
settings: function(next) {
|
||||
user.getSettings(socket.uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var start = parseInt(data.after, 10),
|
||||
end = start + settings.topicsPerPage - 1;
|
||||
end = start + results.settings.topicsPerPage - 1;
|
||||
|
||||
categories.getCategoryTopics(data.cid, start, end, socket.uid, callback);
|
||||
categories.getCategoryTopics(data.cid, start, end, socket.uid, function(err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
data.privileges = results.privileges;
|
||||
callback(null, data);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user