diff --git a/install/package.json b/install/package.json index 7deca8851a..d86a24dc7c 100644 --- a/install/package.json +++ b/install/package.json @@ -75,9 +75,9 @@ "nodebb-plugin-spam-be-gone": "0.5.3", "nodebb-rewards-essentials": "0.0.11", "nodebb-theme-lavender": "5.0.4", - "nodebb-theme-persona": "9.0.7", - "nodebb-theme-slick": "1.2.2", - "nodebb-theme-vanilla": "10.0.7", + "nodebb-theme-persona": "9.0.8", + "nodebb-theme-slick": "1.2.3", + "nodebb-theme-vanilla": "10.0.8", "nodebb-widget-essentials": "4.0.4", "nodemailer": "4.6.4", "passport": "^0.4.0", diff --git a/public/language/en-GB/admin/settings/reputation.json b/public/language/en-GB/admin/settings/reputation.json index c698592cff..517ebe7444 100644 --- a/public/language/en-GB/admin/settings/reputation.json +++ b/public/language/en-GB/admin/settings/reputation.json @@ -8,5 +8,7 @@ "min-rep-flag": "Minimum reputation to flag posts", "min-rep-website": "Minimum reputation to add \"Website\" to user profile", "min-rep-aboutme": "Minimum reputation to add \"About me\" to user profile", - "min-rep-signature": "Minimum reputation to add \"Signature\" to user profile" + "min-rep-signature": "Minimum reputation to add \"Signature\" to user profile", + "min-rep-profile-picture": "Minimum repuration to add \"Profile Picture\" to user profile", + "min-rep-cover-picture": "Minimum repuration to add \"Cover Picture\" to user profile" } \ No newline at end of file diff --git a/public/language/en-GB/error.json b/public/language/en-GB/error.json index cb4ed098ac..7514803f10 100644 --- a/public/language/en-GB/error.json +++ b/public/language/en-GB/error.json @@ -152,6 +152,8 @@ "not-enough-reputation-min-rep-website": "You do not have enough reputation to add a website", "not-enough-reputation-min-rep-aboutme": "You do not have enough reputation to add an about me", "not-enough-reputation-min-rep-signature": "You do not have enough reputation to add a signature", + "not-enough-reputation-min-rep-profile-picture": "You do not have enough reputation to add a profile picture", + "not-enough-reputation-min-rep-cover-picture": "You do not have enough reputation to add a cover picture", "already-flagged": "You have already flagged this post", "self-vote": "You cannot vote on your own post", diff --git a/src/controllers/accounts/edit.js b/src/controllers/accounts/edit.js index af92cdc7bc..3b1c154d1b 100644 --- a/src/controllers/accounts/edit.js +++ b/src/controllers/accounts/edit.js @@ -34,6 +34,8 @@ editController.get = function (req, res, callback) { userData.maximumSignatureLength = parseInt(meta.config.maximumSignatureLength, 10) || 255; userData.maximumAboutMeLength = parseInt(meta.config.maximumAboutMeLength, 10) || 1000; userData.maximumProfileImageSize = parseInt(meta.config.maximumProfileImageSize, 10); + userData.allowProfilePicture = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:profile-picture'], 10) || 0); + userData.allowCoverPicture = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:cover-picture'], 10) || 0); userData.allowProfileImageUploads = parseInt(meta.config.allowProfileImageUploads, 10) === 1; userData.allowMultipleBadges = parseInt(meta.config.allowMultipleBadges, 10) === 1; userData.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1; @@ -163,7 +165,9 @@ editController.uploadPicture = function (req, res, next) { if (!isAllowed) { return helpers.notAllowed(req, res); } - + user.checkMinReputation(req.uid, updateUid, 'min:rep:profile-picture', next); + }, + function (next) { user.uploadCroppedPicture({ uid: updateUid, file: userPhoto, @@ -186,15 +190,21 @@ editController.uploadCoverPicture = function (req, res, next) { var params = JSON.parse(req.body.params); var coverPhoto = req.files.files[0]; - user.updateCoverPicture({ - file: coverPhoto, - uid: params.uid, - }, function (err, image) { + async.waterfall([ + function (next) { + user.checkMinReputation(req.uid, params.uid, 'min:rep:cover-picture', next); + }, + function (next) { + user.updateCoverPicture({ + file: coverPhoto, + uid: params.uid, + }, next); + }, + ], function (err, image) { file.delete(coverPhoto.path); if (err) { return next(err); } - res.json([{ url: image.url, }]); diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js index 5d33e198fc..14f04b6d45 100644 --- a/src/controllers/accounts/profile.js +++ b/src/controllers/accounts/profile.js @@ -80,6 +80,7 @@ profileController.get = function (req, res, callback) { userData.nextStart = results.posts.nextStart; userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username }]); userData.title = userData.username; + userData.allowCoverPicture = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:cover-picture'], 10) || 0); var pageCount = Math.ceil(userData.postcount / itemsPerPage); userData.pagination = pagination.create(page, pageCount, req.query); diff --git a/src/socket.io/user/profile.js b/src/socket.io/user/profile.js index d025b223a2..49e63744c6 100644 --- a/src/socket.io/user/profile.js +++ b/src/socket.io/user/profile.js @@ -31,6 +31,9 @@ module.exports = function (SocketUser) { function (next) { user.isAdminOrGlobalModOrSelf(socket.uid, data.uid, next); }, + function (next) { + user.checkMinReputation(socket.uid, data.uid, 'min:rep:cover-picture', next); + }, function (next) { user.updateCoverPicture(data, next); }, @@ -45,6 +48,9 @@ module.exports = function (SocketUser) { function (next) { user.isAdminOrGlobalModOrSelf(socket.uid, data.uid, next); }, + function (next) { + user.checkMinReputation(socket.uid, data.uid, 'min:rep:profile-picture', next); + }, function (next) { user.uploadCroppedPicture(data, next); }, @@ -204,15 +210,14 @@ module.exports = function (SocketUser) { SocketUser.toggleBlock = function (socket, data, callback) { async.waterfall([ function (next) { - user.blocks.can(data.uid, function (err, can) { - if (err || !can) { - return next(err || new Error('[[error:cannot-block-privileged]]')); - } - - next(); - }); + user.blocks.can(data.uid, next); + }, + function (can, next) { + if (!can) { + return next(new Error('[[error:cannot-block-privileged]]')); + } + user.blocks.is(data.uid, socket.uid, next); }, - async.apply(user.blocks.is, data.uid, socket.uid), function (is, next) { user.blocks[is ? 'remove' : 'add'](data.uid, socket.uid, next); }, diff --git a/src/user/profile.js b/src/user/profile.js index 1af4821f49..fc320bd5d0 100644 --- a/src/user/profile.js +++ b/src/user/profile.js @@ -144,7 +144,7 @@ module.exports = function (User) { if (!data.website) { return setImmediate(callback); } - checkMinReputation(callerUid, data.uid, 'min:rep:website', callback); + User.checkMinReputation(callerUid, data.uid, 'min:rep:website', callback); } function isAboutMeValid(callerUid, data, callback) { @@ -155,7 +155,7 @@ module.exports = function (User) { return callback(new Error('[[error:about-me-too-long, ' + meta.config.maximumAboutMeLength + ']]')); } - checkMinReputation(callerUid, data.uid, 'min:rep:aboutme', callback); + User.checkMinReputation(callerUid, data.uid, 'min:rep:aboutme', callback); } function isSignatureValid(callerUid, data, callback) { @@ -165,10 +165,10 @@ module.exports = function (User) { if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) { return callback(new Error('[[error:signature-too-long, ' + meta.config.maximumSignatureLength + ']]')); } - checkMinReputation(callerUid, data.uid, 'min:rep:signature', callback); + User.checkMinReputation(callerUid, data.uid, 'min:rep:signature', callback); } - function checkMinReputation(callerUid, uid, setting, callback) { + User.checkMinReputation = function (callerUid, uid, setting, callback) { var isSelf = parseInt(callerUid, 10) === parseInt(uid, 10); if (!isSelf) { return setImmediate(callback); @@ -184,7 +184,7 @@ module.exports = function (User) { next(); }, ], callback); - } + }; function updateEmail(uid, newEmail, callback) { async.waterfall([ diff --git a/src/views/admin/settings/reputation.tpl b/src/views/admin/settings/reputation.tpl index 7843273d2d..b05e7e8238 100644 --- a/src/views/admin/settings/reputation.tpl +++ b/src/views/admin/settings/reputation.tpl @@ -37,6 +37,8 @@ [[admin/settings/reputation:min-rep-website]]

[[admin/settings/reputation:min-rep-aboutme]]

[[admin/settings/reputation:min-rep-signature]]

+ [[admin/settings/reputation:min-rep-profile-picture]]

+ [[admin/settings/reputation:min-rep-cover-picture]]