mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
interim commit for moderator support
This commit is contained in:
@@ -50,6 +50,16 @@
|
|||||||
<!-- END active_users -->
|
<!-- END active_users -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="sidebar-block img-polaroid {moderator_block_class}">
|
||||||
|
<div class="block-header">
|
||||||
|
Moderators
|
||||||
|
</div>
|
||||||
|
<div class="block-content">
|
||||||
|
<!-- BEGIN moderators -->
|
||||||
|
<a href="/users/{moderators.username}"><img style="width: 48px; height: 48px; /*temporary*/" src="/graph/users/{moderators.username}/picture" class="img-polaroid" /></a>
|
||||||
|
<!-- END moderators -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,20 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Categories.getModerators = function(cid, callback) {
|
||||||
|
RDB.smembers('cid:' + cid + ':moderators', function(err, mods) {
|
||||||
|
user.getMultipleUserFields(mods, ['username'], function(details) {
|
||||||
|
var moderators = [];
|
||||||
|
for(u in details) {
|
||||||
|
if (details.hasOwnProperty(u)) {
|
||||||
|
moderators.push({ username: details[u].username });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback(moderators);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Categories.get_category = function(cids, callback) {
|
Categories.get_category = function(cids, callback) {
|
||||||
var name = [],
|
var name = [],
|
||||||
description = [],
|
description = [],
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ var RDB = require('./redis.js'),
|
|||||||
marked = require('marked'),
|
marked = require('marked'),
|
||||||
user = require('./user.js'),
|
user = require('./user.js'),
|
||||||
topics = require('./topics.js'),
|
topics = require('./topics.js'),
|
||||||
config = require('../config.js');
|
config = require('../config.js'),
|
||||||
|
async = require('async');
|
||||||
|
|
||||||
marked.setOptions({
|
marked.setOptions({
|
||||||
breaks: true
|
breaks: true
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var fs = require('fs');
|
|||||||
Templates.init = function() {
|
Templates.init = function() {
|
||||||
loadTemplates([
|
loadTemplates([
|
||||||
'header', 'footer', 'register', 'home', 'topic', 'account', 'friends',
|
'header', 'footer', 'register', 'home', 'topic', 'account', 'friends',
|
||||||
'login', 'reset', 'reset_code', 'logout',
|
'login', 'reset', 'reset_code',
|
||||||
'403',
|
'403',
|
||||||
'admin/header', 'admin/footer', 'admin/index',
|
'admin/header', 'admin/footer', 'admin/index',
|
||||||
'emails/header', 'emails/footer',
|
'emails/header', 'emails/footer',
|
||||||
|
|||||||
@@ -81,10 +81,11 @@ var RDB = require('./redis.js'),
|
|||||||
recent_author = replies[11];
|
recent_author = replies[11];
|
||||||
|
|
||||||
var usernames,
|
var usernames,
|
||||||
has_read;
|
has_read,
|
||||||
|
moderators;
|
||||||
|
|
||||||
function generate_topic() {
|
function generate_topic() {
|
||||||
if (!usernames || !has_read) return;
|
if (!usernames || !has_read || !moderators) return;
|
||||||
|
|
||||||
|
|
||||||
for (var i=0, ii=title.length; i<ii; i++) {
|
for (var i=0, ii=title.length; i<ii; i++) {
|
||||||
@@ -125,7 +126,8 @@ var RDB = require('./redis.js'),
|
|||||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||||
'category_id': category_id || 0,
|
'category_id': category_id || 0,
|
||||||
'topics': topics,
|
'topics': topics,
|
||||||
'active_users': active_users
|
'active_users': active_users,
|
||||||
|
'moderators': moderators
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +140,11 @@ var RDB = require('./redis.js'),
|
|||||||
has_read = hasRead;
|
has_read = hasRead;
|
||||||
generate_topic();
|
generate_topic();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
categories.getModerators(category_id, function(mods) {
|
||||||
|
moderators = mods;
|
||||||
|
generate_topic();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
callback({
|
callback({
|
||||||
@@ -147,9 +154,6 @@ var RDB = require('./redis.js'),
|
|||||||
'topics': []
|
'topics': []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -505,6 +505,12 @@ var config = require('../config.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
User.isModerator = function(uid, cid, callback) {
|
||||||
|
RDB.sismember(uid, 'cid:' + cid + ':moderators', function(err, exists) {
|
||||||
|
callback(exists);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
User.reset = {
|
User.reset = {
|
||||||
validate: function(socket, code, callback) {
|
validate: function(socket, code, callback) {
|
||||||
if (typeof callback !== 'function') callback = undefined;
|
if (typeof callback !== 'function') callback = undefined;
|
||||||
|
|||||||
@@ -207,8 +207,8 @@ var express = require('express'),
|
|||||||
app.get('/api/:method/:id*', api_method);
|
app.get('/api/:method/:id*', api_method);
|
||||||
|
|
||||||
app.get('/test', function(req, res) {
|
app.get('/test', function(req, res) {
|
||||||
posts.getRawContent(11, function(post) {
|
categories.getModerators(2, function(mods) {
|
||||||
res.send(JSON.stringify(post));
|
res.send(JSON.stringify(mods));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user