Skip to content

Node.js based forum software built for the modern web

ability to set moderation note on users

barisusakli15cae8d6eae7
diff --git a/package.json b/package.json
index bf82a4584f..ec9c793eb6 100644
--- a/package.json
+++ b/package.json
@@ -61,8 +61,8 @@
"nodebb-plugin-spam-be-gone": "0.4.10",
"nodebb-rewards-essentials": "0.0.9",
"nodebb-theme-lavender": "3.0.14",
- "nodebb-theme-persona": "4.1.47",
- "nodebb-theme-vanilla": "5.1.31",
+ "nodebb-theme-persona": "4.1.48",
+ "nodebb-theme-vanilla": "5.1.32",
"nodebb-widget-essentials": "2.0.11",
"nodemailer": "2.0.0",
"nodemailer-sendmail-transport": "1.0.0",
diff --git a/public/language/en_GB/global.json b/public/language/en_GB/global.json
index e2785de2f5..1881b53acb 100644
--- a/public/language/en_GB/global.json
+++ b/public/language/en_GB/global.json
@@ -23,6 +23,7 @@
"you_have_successfully_logged_in": "You have successfully logged in",
"save_changes": "Save Changes",
+ "save": "Save",
"close": "Close",
"pagination": "Pagination",
diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.json
index 4dfd450cff..10a21ff03e 100644
--- a/public/language/en_GB/user.json
+++ b/public/language/en_GB/user.json
@@ -142,5 +142,7 @@
"info.banned-reason-label": "Reason",
"info.banned-no-reason": "No reason given.",
"info.username-history": "Username History",
- "info.email-history": "Email History"
+ "info.email-history": "Email History",
+ "info.moderation-note": "Moderation Note",
+ "info.moderation-note.success": "Moderation note saved"
}
diff --git a/public/src/client/account/info.js b/public/src/client/account/info.js
index b95f68b838..3e1a218827 100644
--- a/public/src/client/account/info.js
+++ b/public/src/client/account/info.js
@@ -1,13 +1,26 @@
'use strict';
-/* globals define */
+/* globals define, socket, ajaxify, app */
define('forum/account/info', ['forum/account/header'], function(header) {
var Info = {};
Info.init = function() {
header.init();
+ handleModerationNote();
};
+ function handleModerationNote() {
+ $('[component="account/save-moderation-note"]').on('click', function() {
+ var note = $('[component="account/moderation-note"]').val();
+ socket.emit('user.setModerationNote', {uid: ajaxify.data.uid, note: note}, function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ app.alertSuccess('[[user:info.moderation-note.success]]');
+ });
+ });
+ }
+
return Info;
});
diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js
index 29bcb1d851..749eca5de8 100644
--- a/src/controllers/accounts/helpers.js
+++ b/src/controllers/accounts/helpers.js
@@ -92,6 +92,7 @@ helpers.getUserDataByUserSlug = function(userslug, callerUID, callback) {
userData.theirid = userData.uid;
userData.isAdmin = isAdmin;
userData.isGlobalModerator = isGlobalModerator;
+ userData.isAdminOrGlobalModerator = isAdmin || isGlobalModerator;
userData.canBan = isAdmin || isGlobalModerator;
userData.canChangePassword = isAdmin || (isSelf && parseInt(meta.config['password:disableEdit'], 10) !== 1);
userData.isSelf = isSelf;
diff --git a/src/socket.io/user.js b/src/socket.io/user.js
index 83539bad3c..453ffed7d2 100644
--- a/src/socket.io/user.js
+++ b/src/socket.io/user.js
@@ -319,5 +319,26 @@ SocketUser.getUserByEmail = function(socket, email, callback) {
apiController.getUserDataByField(socket.uid, 'email', email, callback);
};
+SocketUser.setModerationNote = function(socket, data, callback) {
+ if (!socket.uid || !data || !data.uid) {
+ return callback(new Error('[[error:invalid-data]]'));
+ }
+
+ async.waterfall([
+ function(next) {
+ user.isAdminOrGlobalMod(socket.uid, next);
+ },
+ function(isAdminOrGlobalMod, next) {
+ if (!isAdminOrGlobalMod) {
+ return next(new Error('[[error:no-privileges]]'));
+ }
+ if (data.note) {
+ user.setUserField(data.uid, 'moderationNote', data.note, next);
+ } else {
+ db.deleteObjectField('user:' + data.uid, 'moderationNote', next);
+ }
+ }
+ ], callback);
+};
module.exports = SocketUser;