v1.18.x
barisusakli 9 years ago
parent ed756f18f4
commit bc255110cc

@ -195,7 +195,7 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
return; return;
} }
bootbox.confirm('<b>Warning!</b><br/>Do you really want to delete user(s)?<br/> This action is not reversable, all user data and content will be erased!', function(confirm) { bootbox.confirm('<b>Warning!</b><br/>Do you really want to delete user(s)?<br/> This action is not reversable, only the user account will be deleted, their posts and topics will not be deleled!', function(confirm) {
if (confirm) { if (confirm) {
socket.emit('admin.user.deleteUsers', uids, function(err) { socket.emit('admin.user.deleteUsers', uids, function(err) {
if (err) { if (err) {
@ -210,6 +210,26 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
}); });
}); });
$('.delete-user-and-content').on('click', function() {
var uids = getSelectedUids();
if (!uids.length) {
return;
}
bootbox.confirm('<b>Warning!</b><br/>Do you really want to delete user(s) and their content?<br/> This action is not reversable, all user data and content will be erased!', function(confirm) {
if (confirm) {
socket.emit('admin.user.deleteUsersAndContent', uids, function(err) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('User(s) Deleted!');
removeSelected();
unselectAll();
});
}
});
});
function handleUserCreate() { function handleUserCreate() {
var errorEl = $('#create-modal-error'); var errorEl = $('#create-modal-error');
$('#createUser').on('click', function() { $('#createUser').on('click', function() {

@ -142,6 +142,18 @@ User.sendPasswordResetEmail = function(socket, uids, callback) {
}; };
User.deleteUsers = function(socket, uids, callback) { User.deleteUsers = function(socket, uids, callback) {
deleteUsers(socket, uids, function(uid, next) {
user.deleteAccount(uid, next);
}, callback);
};
User.deleteUsersAndContent = function(socket, uids, callback) {
deleteUsers(socket, uids, function(uid, next) {
user.delete(socket.uid, uid, next);
}, callback);
};
function deleteUsers(socket, uids, method, callback) {
if (!Array.isArray(uids)) { if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]')); return callback(new Error('[[error:invalid-data]]'));
} }
@ -156,7 +168,7 @@ User.deleteUsers = function(socket, uids, callback) {
return next(new Error('[[error:cant-delete-other-admins]]')); return next(new Error('[[error:cant-delete-other-admins]]'));
} }
user.delete(socket.uid, uid, next); method(uid, next);
}, },
function (next) { function (next) {
events.log({ events.log({
@ -169,7 +181,7 @@ User.deleteUsers = function(socket, uids, callback) {
} }
], next); ], next);
}, callback); }, callback);
}; }
User.search = function(socket, data, callback) { User.search = function(socket, data, callback) {
user.search({query: data.query, searchBy: data.searchBy, uid: socket.uid}, function(err, searchData) { user.search({query: data.query, searchBy: data.searchBy, uid: socket.uid}, function(err, searchData) {

@ -30,6 +30,7 @@
<li><a href="#" class="reset-flags"><i class="fa fa-fw fa-flag"></i> Reset Flags</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 class="divider"></li>
<li><a href="#" class="delete-user"><i class="fa fa-fw fa-trash-o"></i> Delete User(s)</a></li> <li><a href="#" class="delete-user"><i class="fa fa-fw fa-trash-o"></i> Delete User(s)</a></li>
<li><a href="#" class="delete-user-and-content"><i class="fa fa-fw fa-trash-o"></i> Delete User(s) and Content</a></li>
</ul> </ul>
</div> </div>
</ul> </ul>

Loading…
Cancel
Save