Skip to content

Node.js based forum software built for the modern web

components: account/ban, account/unban, account/delete

psychobunnydd8a77b949b9
diff --git a/public/src/client/account/header.js b/public/src/client/account/header.js
index eed177b1d7..8a55177d24 100644
--- a/public/src/client/account/header.js
+++ b/public/src/client/account/header.js
@@ -22,16 +22,20 @@ define('forum/account/header', [
}
components.get('account/follow').on('click', function() {
- return toggleFollow('follow');
+ toggleFollow('follow');
});
components.get('account/unfollow').on('click', function() {
- return toggleFollow('unfollow');
+ toggleFollow('unfollow');
});
components.get('account/chat').on('click', function() {
app.openChat($('.account-username').html(), theirid);
});
+
+ components.get('account/ban').on('click', banAccount);
+ components.get('account/unban').on('click', unbanAccount);
+ components.get('account/delete').on('click', deleteAccount);
};
function hidePrivateLinks() {
@@ -83,5 +87,50 @@ define('forum/account/header', [
return false;
}
+ function banAccount() {
+ translator.translate('[[user:ban_account_confirm]]', function(translated) {
+ bootbox.confirm(translated, function(confirm) {
+ if (!confirm) {
+ return;
+ }
+ socket.emit('admin.user.banUsers', [ajaxify.data.theirid], function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ $('#banAccountBtn').toggleClass('hide', true);
+ $('#banLabel, #unbanAccountBtn').toggleClass('hide', false);
+ });
+ });
+ });
+ }
+
+ function unbanAccount() {
+ socket.emit('admin.user.unbanUsers', [ajaxify.data.theirid], function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ $('#banAccountBtn').toggleClass('hide', false);
+ $('#banLabel, #unbanAccountBtn').toggleClass('hide', true);
+ });
+ }
+
+ function deleteAccount() {
+ translator.translate('[[user:delete_this_account_confirm]]', function(translated) {
+ bootbox.confirm(translated, function(confirm) {
+ if (!confirm) {
+ return;
+ }
+
+ socket.emit('admin.user.deleteUsers', [ajaxify.data.theirid], function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ app.alertSuccess('[[user:account-deleted]]');
+ history.back();
+ });
+ });
+ });
+ }
+
return AccountHeader;
});
diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js
index 080e1b0d56..506f911c74 100644
--- a/public/src/client/account/profile.js
+++ b/public/src/client/account/profile.js
@@ -25,10 +25,6 @@ define('forum/account/profile', [
processPage();
updateButtons();
- $('#banAccountBtn').on('click', banAccount);
- $('#unbanAccountBtn').on('click', unbanAccount);
- $('#deleteAccountBtn').on('click', deleteAccount);
-
socket.removeListener('event:user_status_change', onUserStatusChange);
socket.on('event:user_status_change', onUserStatusChange);
@@ -93,50 +89,5 @@ define('forum/account/profile', [
});
}
- function banAccount() {
- translator.translate('[[user:ban_account_confirm]]', function(translated) {
- bootbox.confirm(translated, function(confirm) {
- if (!confirm) {
- return;
- }
- socket.emit('admin.user.banUsers', [ajaxify.data.theirid], function(err) {
- if (err) {
- return app.alertError(err.message);
- }
- $('#banAccountBtn').toggleClass('hide', true);
- $('#banLabel, #unbanAccountBtn').toggleClass('hide', false);
- });
- });
- });
- }
-
- function unbanAccount() {
- socket.emit('admin.user.unbanUsers', [ajaxify.data.theirid], function(err) {
- if (err) {
- return app.alertError(err.message);
- }
- $('#banAccountBtn').toggleClass('hide', false);
- $('#banLabel, #unbanAccountBtn').toggleClass('hide', true);
- });
- }
-
- function deleteAccount() {
- translator.translate('[[user:delete_this_account_confirm]]', function(translated) {
- bootbox.confirm(translated, function(confirm) {
- if (!confirm) {
- return;
- }
-
- socket.emit('admin.user.deleteUsers', [ajaxify.data.theirid], function(err) {
- if (err) {
- return app.alertError(err.message);
- }
- app.alertSuccess('[[user:account-deleted]]');
- history.back();
- });
- });
- });
- }
-
return Account;
});