ban controls on frontend, closes #4807

v1.18.x
Julian Lam 9 years ago
parent 37b1d1a050
commit 21caa82b61

@ -45,18 +45,4 @@
} }
} }
} }
}
.page-manage-users {
.ban-modal {
input[type="number"] {
width: 5rem;
text-align: center;
margin-left: 1rem;
}
.form-inline, .form-group {
width: 100%;
}
}
} }

@ -103,4 +103,16 @@
&.avatar-rounded { &.avatar-rounded {
border-radius: 50%; border-radius: 50%;
} }
}
.ban-modal {
input[type="number"] {
width: 7rem;
text-align: center;
margin-left: 1rem;
}
.form-inline, .form-group {
width: 100%;
}
} }

@ -103,18 +103,34 @@ define('forum/account/header', [
} }
function banAccount() { function banAccount() {
translator.translate('[[user:ban_account_confirm]]', function(translated) { templates.parse('admin/partials/temporary-ban', {}, function(html) {
bootbox.confirm(translated, function(confirm) { bootbox.dialog({
if (!confirm) { className: 'ban-modal',
return; title: '[[user:ban_account]]',
} message: html,
socket.emit('user.banUsers', [ajaxify.data.theirid], function(err) { show: true,
if (err) { buttons: {
return app.alertError(err.message); close: {
label: '[[global:close]]',
className: 'btn-link'
},
submit: {
label: '[[user:ban_account]]',
callback: function() {
var formData = $('.ban-modal form').serializeArray().reduce(function(data, cur) {
data[cur.name] = cur.value;
return data;
}, {});
var until = Date.now() + formData.length * 1000*60*60 * (parseInt(formData.unit, 10) ? 24 : 1);
socket.emit('user.banUsers', { uids: [ajaxify.data.theirid], until: until }, function(err) {
if (err) {
return app.alertError(err.message);
}
ajaxify.refresh();
});
}
} }
components.get('account/ban').parent().addClass('hide'); }
components.get('account/unban').parent().removeClass('hide');
});
}); });
}); });
} }
@ -124,9 +140,7 @@ define('forum/account/header', [
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
ajaxify.refresh();
components.get('account/ban').parent().removeClass('hide');
components.get('account/unban').parent().addClass('hide');
}); });
} }

@ -60,7 +60,7 @@ module.exports = function(User) {
db.sortedSetScores('users:banned:expire', uids, function(err, scores) { db.sortedSetScores('users:banned:expire', uids, function(err, scores) {
users = users.map(function(userObj, idx) { users = users.map(function(userObj, idx) {
userObj.banned_until = scores[idx] || 0; userObj.banned_until = scores[idx] || 0;
userObj.banned_until_readable = scores[idx] ? new Date(scores[idx]).toISOString() : 'Not Banned'; userObj.banned_until_readable = scores[idx] ? new Date(scores[idx]).toString() : 'Not Banned';
}); });
}); });
} }

Loading…
Cancel
Save