diff --git a/public/language/en-GB/user.json b/public/language/en-GB/user.json
index aa43c69e4c..448831efd4 100644
--- a/public/language/en-GB/user.json
+++ b/public/language/en-GB/user.json
@@ -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?
This action is irreversible and you will not be able to recover any of your data
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?
This action is irreversible and you will not be able to recover any data
",
+ "delete_account_as_admin": "Delete Account",
+ "delete_content": "Delete Account Content",
+ "delete_all": "Delete Account and Content",
+ "delete_account_confirm": "Are you sure you want to anonymize your posts and delete your account?
This action is irreversible and you will not be able to recover any of your data
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?
This action is irreversible, posts will be anonymized, and you will not be able to restore post associations with the deleted account
",
"delete_account_content_confirm": "Are you sure you want to delete this account's content (posts/topics/uploads)?
This action is irreversible and you will not be able to recover any data
",
+ "delete_all_confirm": "Are you sure you want to delete this account and all of its content (posts/topics/uploads)?
This action is irreversible and you will not be able to recover any data
",
"account-deleted": "Account deleted",
"account-content-deleted": "Account content deleted",
diff --git a/public/src/client/account/header.js b/public/src/client/account/header.js
index a8620ed98e..ac4549610e 100644
--- a/public/src/client/account/header.js
+++ b/public/src/client/account/header.js
@@ -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({
diff --git a/public/src/client/flags/detail.js b/public/src/client/flags/detail.js
index 1f8ecbb1e2..cdb1e4fc89 100644
--- a/public/src/client/flags/detail.js
+++ b/public/src/client/flags/detail.js
@@ -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':
diff --git a/public/src/modules/accounts/delete.js b/public/src/modules/accounts/delete.js
new file mode 100644
index 0000000000..06a9003c79
--- /dev/null
+++ b/public/src/modules/accounts/delete.js
@@ -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;
+});