mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
ability to set moderation note on users
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"you_have_successfully_logged_in": "You have successfully logged in",
|
||||
|
||||
"save_changes": "Save Changes",
|
||||
"save": "Save",
|
||||
"close": "Close",
|
||||
|
||||
"pagination": "Pagination",
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user