feat: #8384 options to delete account, content, or both

v1.18.x
Julian Lam 5 years ago
parent 942cc4b132
commit 4d60eac60f

@ -9,14 +9,18 @@
"email": "Email",
"confirm_email": "Confirm Email",
"account_info": "Account Info",
"admin_actions_label": "Administrative Actions",
"ban_account": "Ban Account",
"ban_account_confirm": "Do you really want to ban this user?",
"unban_account": "Unban Account",
"delete_account": "Delete Account",
"delete_content": "Delete Account Content Only",
"delete_account_confirm": "Are you sure you want to delete your account? <br /><strong>This action is irreversible and you will not be able to recover any of your data</strong><br /><br />Enter your password to confirm that you wish to destroy this account.",
"delete_this_account_confirm": "Are you sure you want to delete this account? <br /><strong>This action is irreversible and you will not be able to recover any data</strong><br /><br />",
"delete_account_as_admin": "Delete <strong>Account</strong>",
"delete_content": "Delete Account <strong>Content</strong>",
"delete_all": "Delete <strong>Account</strong> and <strong>Content</strong>",
"delete_account_confirm": "Are you sure you want to anonymize your posts and delete your account?<br /><strong>This action is irreversible and you will not be able to recover any of your data</strong><br /><br />Enter your password to confirm that you wish to destroy this account.",
"delete_this_account_confirm": "Are you sure you want to delete this account while leaving its contents behind?<br /><strong>This action is irreversible, posts will be anonymized, and you will not be able to restore post associations with the deleted account</strong><br /><br />",
"delete_account_content_confirm": "Are you sure you want to delete this account's content (posts/topics/uploads)? <br /><strong>This action is irreversible and you will not be able to recover any data</strong><br /><br />",
"delete_all_confirm": "Are you sure you want to delete this account and all of its content (posts/topics/uploads)? <br /><strong>This action is irreversible and you will not be able to recover any data</strong><br /><br />",
"account-deleted": "Account deleted",
"account-content-deleted": "Account content deleted",

@ -7,7 +7,8 @@ define('forum/account/header', [
'components',
'translator',
'benchpress',
], function (coverPhoto, pictureCropper, components, translator, Benchpress) {
'accounts/delete',
], function (coverPhoto, pictureCropper, components, translator, Benchpress, AccountsDelete) {
var AccountHeader = {};
var isAdminOrSelfOrGlobalMod;
@ -51,15 +52,19 @@ define('forum/account/header', [
components.get('account/ban').on('click', banAccount);
components.get('account/unban').on('click', unbanAccount);
components.get('account/delete').on('click', deleteAccount);
components.get('account/delete-account').on('click', handleDeleteEvent.bind(null, 'account'));
components.get('account/delete-content').on('click', handleDeleteEvent.bind(null, 'content'));
components.get('account/delete-all').on('click', handleDeleteEvent.bind(null, 'purge'));
components.get('account/flag').on('click', flagAccount);
components.get('account/block').on('click', toggleBlockAccount);
};
// TODO: These exported methods are used in forum/flags/detail -- refactor??
function handleDeleteEvent(type) {
AccountsDelete[type](ajaxify.data.theirid);
}
// TODO: This exported method is used in forum/flags/detail -- refactor??
AccountHeader.banAccount = banAccount;
AccountHeader.deleteAccount = deleteAccount;
AccountHeader.deleteContent = deleteContent;
function hidePrivateLinks() {
if (!app.user.uid || app.user.uid !== parseInt(ajaxify.data.theirid, 10)) {
@ -177,56 +182,6 @@ define('forum/account/header', [
});
}
function deleteAccount(theirid, onSuccess) {
theirid = theirid || ajaxify.data.theirid;
translator.translate('[[user:delete_this_account_confirm]]', function (translated) {
bootbox.confirm(translated, function (confirm) {
if (!confirm) {
return;
}
socket.emit('admin.user.deleteUsersAndContent', [theirid], function (err) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[user:account-deleted]]');
if (typeof onSuccess === 'function') {
return onSuccess();
}
history.back();
});
});
});
}
function deleteContent(theirid, onSuccess) {
theirid = theirid || ajaxify.data.theirid;
translator.translate('[[user:delete_account_content_confirm]]', function (translated) {
bootbox.confirm(translated, function (confirm) {
if (!confirm) {
return;
}
socket.emit('admin.user.deleteUsersContent', [theirid], function (err) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[user:account-content-deleted]]');
if (typeof onSuccess === 'function') {
return onSuccess();
}
history.back();
});
});
});
}
function flagAccount() {
require(['flags'], function (flags) {
flags.showFlagModal({

@ -1,6 +1,6 @@
'use strict';
define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'benchpress', 'forum/account/header'], function (FlagsList, components, translator, Benchpress, AccountHeader) {
define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'benchpress', 'forum/account/header', 'accounts/delete'], function (FlagsList, components, translator, Benchpress, AccountHeader, AccountsDelete) {
var Detail = {};
Detail.init = function () {
@ -49,11 +49,15 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
break;
case 'delete-account':
AccountHeader.deleteAccount(uid, ajaxify.refresh);
AccountsDelete.account(uid, ajaxify.refresh);
break;
case 'delete-content':
AccountHeader.deleteContent(uid, ajaxify.refresh);
AccountsDelete.content(uid, ajaxify.refresh);
break;
case 'delete-all':
AccountsDelete.purge(uid, ajaxify.refresh);
break;
case 'delete-post':

@ -0,0 +1,58 @@
'use strict';
define('accounts/delete', [], function () {
var Delete = {};
Delete.account = function (uid, callback) {
executeAction(
uid,
'[[user:delete_this_account_confirm]]',
'admin.user.deleteUsers',
'[[user:account-deleted]]',
callback
);
};
Delete.content = function (uid, callback) {
executeAction(
uid,
'[[user:delete_account_content_confirm]]',
'admin.user.deleteUsersContent',
'[[user:account-content-deleted]]',
callback
);
};
Delete.purge = function (uid, callback) {
executeAction(
uid,
'[[user:delete_all_confirm]]',
'admin.user.deleteUsersAndContent',
'[[user:account-deleted]]',
callback
);
};
function executeAction(uid, confirmText, action, successText, callback) {
bootbox.confirm(confirmText, function (confirm) {
if (!confirm) {
return;
}
socket.emit(action, [uid], function (err) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess(successText);
if (typeof callback === 'function') {
return callback();
}
history.back();
});
});
}
return Delete;
});
Loading…
Cancel
Save