add label to banned users, dont hide their posts

v1.18.x
Baris Soner Usakli 12 years ago
parent 74af205426
commit 999e98e43d

@ -197,6 +197,12 @@ footer.footer {
font-weight:bold; font-weight:bold;
} }
.account-block {
div {
padding-bottom:10px;
}
}
.account-picture-block{ .account-picture-block{
display:inline-block; display:inline-block;
vertical-align:top; vertical-align:top;
@ -213,7 +219,6 @@ footer.footer {
.user-profile-picture { .user-profile-picture {
width:128px; width:128px;
margin-bottom:10px;
} }
.user-picture-label { .user-picture-label {

@ -17,13 +17,16 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span2" style="text-align: center; margin-bottom:20px;"> <div class="span2 account-block" style="text-align: center; margin-bottom:20px;">
<div class="account-picture-block"> <div class="account-picture-block">
<img src="{picture}" class="user-profile-picture img-polaroid"/> <img src="{picture}" class="user-profile-picture img-polaroid"/>
</div> </div>
<div class="account-online-status"> <div class="account-online-status">
<span><i class="icon-circle-blank"></i> <span>offline</span></span> <span><i class="icon-circle-blank"></i> <span>offline</span></span>
</div> </div>
<div class="{show_banned}">
<span class="label label-important">banned</span>
</div>
<div id="user-actions"> <div id="user-actions">
<a id="follow-btn" href="#" class="btn hide">Follow</a> <a id="follow-btn" href="#" class="btn hide">Follow</a>
<a id="unfollow-btn" href="#" class="btn hide">Unfollow</a> <a id="unfollow-btn" href="#" class="btn hide">Unfollow</a>

@ -89,6 +89,7 @@
<i class="icon-star"></i><span class="user_rep_{posts.uid} formatted-number">{posts.user_rep}</span> <i class="icon-star"></i><span class="user_rep_{posts.uid} formatted-number">{posts.user_rep}</span>
<div id="ids_{posts.pid}_{posts.uid}" class="chat hidden-phone" title="Chat"><i class="icon-comment"></i></div> <div id="ids_{posts.pid}_{posts.uid}" class="chat hidden-phone" title="Chat"><i class="icon-comment"></i></div>
</div> </div>
<span class="label label-important {posts.show_banned}">banned</span>
</div> </div>
<div class="span11 span12-tablet"> <div class="span11 span12-tablet">
<div class="post-block"> <div class="post-block">

@ -55,8 +55,7 @@ var RDB = require('./redis.js'),
} }
function getActiveUsers(next) { function getActiveUsers(next) {
user.getMultipleUserFields(active_users, ['username', 'userslug', 'picture', 'banned'], function(users) { user.getMultipleUserFields(active_users, ['username', 'userslug', 'picture'], function(users) {
users = user.filterBannedUsers(users);
next(null, users); next(null, users);
}); });
} }
@ -201,7 +200,6 @@ var RDB = require('./redis.js'),
} }
posts.getPostSummaryByPids(pids, function(postData) { posts.getPostSummaryByPids(pids, function(postData) {
postData = posts.filterBannedPosts(postData);
if(postData.length > count) { if(postData.length > count) {
postData = postData.slice(0, count); postData = postData.slice(0, count);
} }

@ -64,19 +64,13 @@ var user = require('./../user.js'),
user.get_uid_by_userslug(req.params.userslug, function(uid) { user.get_uid_by_userslug(req.params.userslug, function(uid) {
if(!uid) { if(!uid) {
next(); return next();
return;
} }
user.getUserField(uid, 'banned', function(banned) { app.build_header({ req: req, res: res }, function(err, header) {
if(banned && banned === '1') { res.send(header + app.create_route('users/' + req.params.userslug, 'account') + templates['footer']);
next();
} else {
app.build_header({ req: req, res: res }, function(err, header) {
res.send(header + app.create_route('users/' + req.params.userslug, 'account') + templates['footer']);
});
}
}); });
}); });
}); });
@ -327,21 +321,18 @@ var user = require('./../user.js'),
function getUsersSortedByJoinDate(req, res) { function getUsersSortedByJoinDate(req, res) {
user.getUsers('users:joindate', 0, 49, function(err, data) { user.getUsers('users:joindate', 0, 49, function(err, data) {
data = user.filterBannedUsers(data);
res.json({ search_display: 'none', loadmore_display:'block', users:data }); res.json({ search_display: 'none', loadmore_display:'block', users:data });
}); });
} }
function getUsersSortedByPosts(req, res) { function getUsersSortedByPosts(req, res) {
user.getUsers('users:postcount', 0, 49, function(err, data) { user.getUsers('users:postcount', 0, 49, function(err, data) {
data = user.filterBannedUsers(data);
res.json({ search_display: 'none', loadmore_display:'block', users:data }); res.json({ search_display: 'none', loadmore_display:'block', users:data });
}); });
} }
function getUsersSortedByReputation(req, res) { function getUsersSortedByReputation(req, res) {
user.getUsers('users:reputation', 0, 49, function(err, data) { user.getUsers('users:reputation', 0, 49, function(err, data) {
data = user.filterBannedUsers(data);
res.json({ search_display: 'none', loadmore_display:'block', users:data }); res.json({ search_display: 'none', loadmore_display:'block', users:data });
}); });
} }
@ -380,6 +371,7 @@ var user = require('./../user.js'),
else else
data.emailClass = "hide"; data.emailClass = "hide";
data.show_banned = data.banned === '1'?'':'hide';
data.uid = uid; data.uid = uid;
data.yourid = callerUID; data.yourid = callerUID;

@ -291,32 +291,14 @@ var RDB = require('./redis.js'),
if(!numPosts) if(!numPosts)
return callback(new Error('no-undeleted-pids-found')); return callback(new Error('no-undeleted-pids-found'));
posts = posts.reverse(); while(numPosts--) {
lastPostId = 0; if(posts[numPosts].deleted !== '1') {
callback(null, posts[numPosts].pid);
function isPostVisible(post, next) { return;
if(post.deleted !== '1') {
user.getUserField(post.uid, 'banned', function(banned) {
if(banned && banned === '1') {
next(null);
} else {
lastPostId = post.pid
next(post.pid);
return;
}
});
} else {
next(null);
} }
} }
async.eachSeries(posts, isPostVisible, function(err) { callback(new Error('no-undeleted-pids-found'));
if(err) {
callback(null, lastPostId);
} else {
callback(new Error('no-undeleted-pids-found'));
}
});
}); });
} }
}(exports)); }(exports));

@ -78,11 +78,10 @@ marked.setOptions({
var fav_data = results[0], var fav_data = results[0],
privileges = results[2]; privileges = results[2];
postData = posts.filterBannedPosts(postData);
for(var i=0; i<postData.length; ++i) { for(var i=0; i<postData.length; ++i) {
postData[i].fav_star_class = fav_data[postData[i].pid] ? 'icon-star' : 'icon-star-empty'; postData[i].fav_star_class = fav_data[postData[i].pid] ? 'icon-star' : 'icon-star-empty';
postData[i]['display_moderator_tools'] = (postData[i].uid == current_user || privileges.editable) ? 'show' : 'none'; postData[i]['display_moderator_tools'] = (postData[i].uid == current_user || privileges.editable) ? 'show' : 'none';
postData[i].show_banned = postData[i].user_banned === '1'?'show':'hide';
} }
callback(postData); callback(postData);
@ -197,7 +196,7 @@ marked.setOptions({
function getTopicInfo(topicData, callback) { function getTopicInfo(topicData, callback) {
function getUserInfo(next) { function getUserInfo(next) {
user.getUserFields(topicData.uid, ['username', 'banned'], function(userData) { user.getUserFields(topicData.uid, ['username'], function(userData) {
next(null, userData); next(null, userData);
}); });
} }
@ -234,10 +233,7 @@ marked.setOptions({
function isTopicVisible(topicData, topicInfo) { function isTopicVisible(topicData, topicInfo) {
var deleted = parseInt(topicData.deleted, 10) !== 0; var deleted = parseInt(topicData.deleted, 10) !== 0;
var banned = false; return !deleted || (deleted && topicInfo.privileges.view_deleted) || topicData.uid === current_user;
if(topicData.userbanned)
banned = parseInt(topicData.userbanned, 10) !== 0;
return !banned && (!deleted || (deleted && topicInfo.privileges.view_deleted) || topicData.uid === current_user);
} }
function loadTopic(tid, callback) { function loadTopic(tid, callback) {
@ -255,7 +251,6 @@ marked.setOptions({
topicData.relativeTime = utils.relativeTime(topicData.timestamp); topicData.relativeTime = utils.relativeTime(topicData.timestamp);
topicData.username = topicInfo.username; topicData.username = topicInfo.username;
topicData.userbanned = topicInfo.userbanned;
topicData.badgeclass = (topicInfo.hasread && current_user != 0) ? '' : 'badge-important'; topicData.badgeclass = (topicInfo.hasread && current_user != 0) ? '' : 'badge-important';
topicData.teaser_text = topicInfo.teaserInfo.text || '', topicData.teaser_text = topicInfo.teaserInfo.text || '',
topicData.teaser_username = topicInfo.teaserInfo.username || ''; topicData.teaser_username = topicInfo.teaserInfo.username || '';

@ -671,7 +671,6 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
if(err) { if(err) {
winston.err(err); winston.err(err);
} else { } else {
data = user.filterBannedUsers(data);
callback({users:data}); callback({users:data});
} }
}); });
@ -720,12 +719,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
socket.on('api:admin.user.search', function(username) { socket.on('api:admin.user.search', function(username) {
if(uid && uid > 0) { if(uid && uid > 0) {
user.search(username, function(data) { user.search(username, function(data) {
user.isAdministrator(uid, function(isAdmin) { socket.emit('api:admin.user.search', data);
if(!isAdmin)
data = user.filterBannedUsers(data);
socket.emit('api:admin.user.search', data);
});
}); });
} else { } else {
socket.emit('api:admin.user.search', null); socket.emit('api:admin.user.search', null);

Loading…
Cancel
Save