ban integration frontend for ACP, #4807

v1.18.x
Julian Lam 9 years ago
parent 915fa99ebe
commit 61fe9594d7

@ -147,5 +147,6 @@
"no-session-found": "No login session found!",
"not-in-room": "User not in room",
"no-users-in-room": "No users in this room",
"cant-kick-self": "You can't kick yourself from the group"
"cant-kick-self": "You can't kick yourself from the group",
"no-users-selected": "No user(s) selected"
}

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

@ -47,25 +47,59 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
$('.ban-user').on('click', function() {
var uids = getSelectedUids();
if (!uids.length) {
return false;
app.alertError('[[error:no-users-selected]]');
return false; // specifically to keep the menu open
}
bootbox.confirm('Do you really want to ban?', function(confirm) {
bootbox.confirm('Do you really want to ban ' + (uids.length > 1 ? 'these users' : 'this user') + ' <strong>permanently</strong>?', function(confirm) {
if (confirm) {
socket.emit('user.banUsers', uids, done('User(s) banned!', '.ban', true));
socket.emit('user.banUsers', { uids: uids }, done('User(s) banned!', '.ban', true));
}
});
return false;
});
$('.ban-user-temporary').on('click', function(e) {
var uids = getSelectedUids();
if (!uids.length) {
app.alertError('[[error:no-users-selected]]');
return false; // specifically to keep the menu open
}
templates.parse('admin/partials/temporary-ban', {}, function(html) {
var modal = bootbox.dialog({
className: 'ban-modal',
title: '[[user:ban_account]]',
message: html,
show: true,
buttons: {
close: {
label: '[[global:close]]',
className: 'btn-link'
},
submit: {
label: 'Ban ' + uids.length + (uids.length > 1 ? ' users' : ' user'),
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: uids, until: until }, done('User(s) banned!', '.ban', true));
}
}
}
});
});
});
$('.unban-user').on('click', function() {
var uids = getSelectedUids();
if (!uids.length) {
return;
app.alertError('[[error:no-users-selected]]');
return false; // specifically to keep the menu open
}
socket.emit('user.unbanUsers', uids, done('User(s) unbanned!', '.ban', false));
return false;
});
$('.reset-lockout').on('click', function() {
@ -75,7 +109,6 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
}
socket.emit('admin.user.resetLockouts', uids, done('Lockout(s) reset!'));
return false;
});
$('.reset-flags').on('click', function() {
@ -85,7 +118,6 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
}
socket.emit('admin.user.resetFlags', uids, done('Flags(s) reset!'));
return false;
});
$('.admin-user').on('click', function() {
@ -99,7 +131,6 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
} else {
socket.emit('admin.user.makeAdmins', uids, done('User(s) are now administrators.', '.administrator', true));
}
return false;
});
$('.remove-admin-user').on('click', function() {
@ -117,7 +148,6 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
}
});
}
return false;
});
$('.validate-email').on('click', function() {
@ -131,7 +161,6 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
socket.emit('admin.user.validateEmail', uids, done('Emails validated', '.notvalidated', false));
}
});
return false;
});
$('.send-validation-email').on('click', function() {
@ -158,7 +187,6 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
socket.emit('admin.user.sendPasswordResetEmail', uids, done('Emails sent'));
}
});
return false;
});
$('.delete-user').on('click', function() {
@ -180,7 +208,6 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
});
}
});
return false;
});
function handleUserCreate() {

@ -23,12 +23,13 @@
<li><a href="#" class="send-validation-email"><i class="fa fa-fw fa-mail-forward"></i> Send Validation Email</a></li>
<li><a href="#" class="password-reset-email"><i class="fa fa-fw fa-key"></i> Send Password Reset Email</a></li>
<li class="divider"></li>
<li><a href="#" class="ban-user"><i class="fa fa-fw fa-gavel"></i> Ban User</a></li>
<li><a href="#" class="unban-user"><i class="fa fa-fw fa-comment-o"></i> Unban User</a></li>
<li><a href="#" class="ban-user"><i class="fa fa-fw fa-gavel"></i> Ban User(s)</a></li>
<li><a href="#" class="ban-user-temporary"><i class="fa fa-fw fa-clock-o"></i> Ban User(s) Temporarily</a></li>
<li><a href="#" class="unban-user"><i class="fa fa-fw fa-comment-o"></i> Unban User(s)</a></li>
<li><a href="#" class="reset-lockout"><i class="fa fa-fw fa-unlock"></i> Reset Lockout</a></li>
<li><a href="#" class="reset-flags"><i class="fa fa-fw fa-flag"></i> Reset Flags</a></li>
<li class="divider"></li>
<li><a href="#" class="delete-user"><i class="fa fa-fw fa-trash-o"></i> Delete User</a></li>
<li><a href="#" class="delete-user"><i class="fa fa-fw fa-trash-o"></i> Delete User(s)</a></li>
</ul>
</div>
</ul>

@ -0,0 +1,13 @@
<form class="form-inline">
<div class="form-group text-center">
<label for="days">Ban Length</label>
<input class="form-control" name="length" type="number" min="1" value="1" /><br />
<label>Hours</label>
<input type="radio" name="unit" value="0" checked />
<label>Days</label>
<input type="radio" name="unit" value="1" />
</div>
<p class="help-block">
Enter the length of time for the ban. Note that a time of 0 will be a considered a permanent ban.
</p>
</form>
Loading…
Cancel
Save