mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05: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) {
|
Category.onTopicsLoaded = function(data, callback) {
|
||||||
if(!topics || !topics.length) {
|
if(!data || !data.topics.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var topics = data.topics;
|
||||||
|
|
||||||
function removeAlreadyAddedTopics() {
|
function removeAlreadyAddedTopics() {
|
||||||
topics = topics.filter(function(topic) {
|
topics = topics.filter(function(topic) {
|
||||||
return $('#topics-container li[data-tid="' + topic.tid +'"]').length === 0;
|
return $('#topics-container li[data-tid="' + topic.tid +'"]').length === 0;
|
||||||
@@ -261,7 +263,7 @@ define(['composer', 'forum/pagination', 'share', 'navigator'], function(composer
|
|||||||
findInsertionPoint();
|
findInsertionPoint();
|
||||||
|
|
||||||
ajaxify.loadTemplate('category', function(categoryTemplate) {
|
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) {
|
translator.translate(html, function(translatedHTML) {
|
||||||
var container = $('#topics-container'),
|
var container = $('#topics-container'),
|
||||||
@@ -309,6 +311,7 @@ define(['composer', 'forum/pagination', 'share', 'navigator'], function(composer
|
|||||||
cid: cid,
|
cid: cid,
|
||||||
after: after
|
after: after
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
|
console.log(data);
|
||||||
loadingMoreTopics = false;
|
loadingMoreTopics = false;
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
@@ -316,7 +319,7 @@ define(['composer', 'forum/pagination', 'share', 'navigator'], function(composer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data && data.topics.length) {
|
if (data && data.topics.length) {
|
||||||
Category.onTopicsLoaded(data.topics, callback);
|
Category.onTopicsLoaded(data, callback);
|
||||||
$('#topics-container').attr('data-nextstart', data.nextStart);
|
$('#topics-container').attr('data-nextstart', data.nextStart);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@@ -68,15 +68,15 @@ categoriesController.get = function(req, res, next) {
|
|||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
categoryTools.privileges(cid, uid, function(err, categoryPrivileges) {
|
categoryTools.privileges(cid, uid, function(err, categoryPrivileges) {
|
||||||
if (!err) {
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
if (!categoryPrivileges.read) {
|
if (!categoryPrivileges.read) {
|
||||||
next(new Error('[[error:no-privileges]]'));
|
next(new Error('[[error:no-privileges]]'));
|
||||||
} else {
|
} else {
|
||||||
next(null, categoryPrivileges);
|
next(null, categoryPrivileges);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
next(err);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (privileges, next) {
|
function (privileges, next) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var categories = require('../categories'),
|
var async = require('async'),
|
||||||
|
categories = require('../categories'),
|
||||||
categoryTools = require('../categoryTools'),
|
categoryTools = require('../categoryTools'),
|
||||||
meta = require('./../meta'),
|
meta = require('./../meta'),
|
||||||
user = require('./../user'),
|
user = require('./../user'),
|
||||||
@@ -30,12 +31,29 @@ SocketCategories.loadMore = function(socket, data, callback) {
|
|||||||
return callback(new Error('[[error:invalid-data]]'));
|
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),
|
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