added about me field

v1.18.x
barisusakli 10 years ago
parent 3063da83ef
commit 9749658d35

@ -83,6 +83,10 @@
"field": "maximumSignatureLength", "field": "maximumSignatureLength",
"value": 255 "value": 255
}, },
{
"field": "maximumAboutMeLength",
"value": 1000
},
{ {
"field": "maximumProfileImageSize", "field": "maximumProfileImageSize",
"value": 256 "value": 256

@ -89,6 +89,7 @@
"uploads-are-disabled": "Uploads are disabled", "uploads-are-disabled": "Uploads are disabled",
"signature-too-long" : "Sorry, your signature cannot be longer than %1 characters.", "signature-too-long" : "Sorry, your signature cannot be longer than %1 characters.",
"about-me-too-long" : "Sorry, your about me cannot be longer than %1 characters.",
"cant-chat-with-yourself": "You can't chat with yourself!", "cant-chat-with-yourself": "You can't chat with yourself!",
"chat-restricted": "This user has restricted their chat messages. They must follow you before you can chat with them", "chat-restricted": "This user has restricted their chat messages. They must follow you before you can chat with them",

@ -23,6 +23,7 @@
"watched": "Watched", "watched": "Watched",
"followers": "Followers", "followers": "Followers",
"following": "Following", "following": "Following",
"aboutme": "About me",
"signature": "Signature", "signature": "Signature",
"gravatar": "Gravatar", "gravatar": "Gravatar",
"birthday": "Birthday", "birthday": "Birthday",

@ -31,6 +31,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
handleEmailConfirm(); handleEmailConfirm();
handlePasswordChange(); handlePasswordChange();
updateSignature(); updateSignature();
updateAboutMe();
updateImages(); updateImages();
}; };
@ -43,7 +44,8 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
website: $('#inputWebsite').val(), website: $('#inputWebsite').val(),
birthday: $('#inputBirthday').val(), birthday: $('#inputBirthday').val(),
location: $('#inputLocation').val(), location: $('#inputLocation').val(),
signature: $('#inputSignature').val() signature: $('#inputSignature').val(),
aboutme: $('#inputAboutMe').val()
}; };
socket.emit('user.updateProfile', userData, function(err, data) { socket.emit('user.updateProfile', userData, function(err, data) {
@ -337,15 +339,25 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
$('#uploaded-box .fa-check').toggle(currentPicture === uploadedPicture); $('#uploaded-box .fa-check').toggle(currentPicture === uploadedPicture);
} }
function getCharsLeft(el, max) {
return el.length ? '(' + el.val().length + '/' + max + ')' : '';
}
function updateSignature() { function updateSignature() {
function getSignatureCharsLeft() { var el = $('#inputSignature');
return $('#inputSignature').length ? '(' + $('#inputSignature').val().length + '/' + config.maximumSignatureLength + ')' : ''; $('#signatureCharCountLeft').html(getCharsLeft(el, config.maximumSignatureLength));
el.on('keyup change', function() {
$('#signatureCharCountLeft').html(getCharsLeft(el, config.maximumSignatureLength));
});
} }
$('#signatureCharCountLeft').html(getSignatureCharsLeft()); function updateAboutMe() {
var el = $('#inputAboutMe');
$('#aboutMeCharCountLeft').html(getCharsLeft(el, config.maximumAboutMeLength));
$('#inputSignature').on('keyup change', function(ev) { el.on('keyup change', function() {
$('#signatureCharCountLeft').html(getSignatureCharsLeft()); $('#aboutMeCharCountLeft').html(getCharsLeft(el, config.maximumAboutMeLength));
}); });
} }

@ -97,6 +97,7 @@ function getUserDataByUserSlug(userslug, callerUID, callback) {
userData.fullname = validator.escape(userData.fullname); userData.fullname = validator.escape(userData.fullname);
userData.location = validator.escape(userData.location); userData.location = validator.escape(userData.location);
userData.signature = validator.escape(userData.signature); userData.signature = validator.escape(userData.signature);
userData.aboutme = validator.escape(userData.aboutme || '');
callback(null, userData); callback(null, userData);
}); });
@ -154,6 +155,13 @@ accountsController.getAccount = function(req, res, next) {
}, },
signature: function(next) { signature: function(next) {
posts.parseSignature(userData, req.uid, next); posts.parseSignature(userData, req.uid, next);
},
aboutme: function(next) {
if (userData.aboutme) {
plugins.fireHook('filter:parse.raw', userData.aboutme, next);
} else {
next();
}
} }
}, function(err, results) { }, function(err, results) {
if(err) { if(err) {
@ -163,7 +171,7 @@ accountsController.getAccount = function(req, res, next) {
userData.posts = results.posts.posts.filter(function (p) { userData.posts = results.posts.posts.filter(function (p) {
return p && parseInt(p.deleted, 10) !== 1; return p && parseInt(p.deleted, 10) !== 1;
}); });
userData.aboutme = results.aboutme;
userData.nextStart = results.posts.nextStart; userData.nextStart = results.posts.nextStart;
userData.isFollowing = results.isFollowing; userData.isFollowing = results.isFollowing;

@ -39,6 +39,7 @@ apiController.getConfig = function(req, res, next) {
config.maximumUsernameLength = meta.config.maximumUsernameLength; config.maximumUsernameLength = meta.config.maximumUsernameLength;
config.minimumPasswordLength = meta.config.minimumPasswordLength; config.minimumPasswordLength = meta.config.minimumPasswordLength;
config.maximumSignatureLength = meta.config.maximumSignatureLength; config.maximumSignatureLength = meta.config.maximumSignatureLength;
config.maximumAboutMeLength = meta.config.maximumAboutMeLength;
config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1; config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1;
config.allowGuestSearching = parseInt(meta.config.allowGuestSearching, 10) === 1; config.allowGuestSearching = parseInt(meta.config.allowGuestSearching, 10) === 1;
config.allowGuestHandles = parseInt(meta.config.allowGuestHandles, 10) === 1; config.allowGuestHandles = parseInt(meta.config.allowGuestHandles, 10) === 1;

@ -16,7 +16,7 @@ var async = require('async'),
module.exports = function(User) { module.exports = function(User) {
User.updateProfile = function(uid, data, callback) { User.updateProfile = function(uid, data, callback) {
var fields = ['username', 'email', 'fullname', 'website', 'location', 'birthday', 'signature']; var fields = ['username', 'email', 'fullname', 'website', 'location', 'birthday', 'signature', 'aboutme'];
plugins.fireHook('filter:user.updateProfile', {uid: uid, data: data, fields: fields}, function(err, data) { plugins.fireHook('filter:user.updateProfile', {uid: uid, data: data, fields: fields}, function(err, data) {
if (err) { if (err) {
@ -26,6 +26,14 @@ module.exports = function(User) {
fields = data.fields; fields = data.fields;
data = data.data; data = data.data;
function isAboutMeValid(next) {
if (data.aboutme !== undefined && data.aboutme.length > meta.config.maximumAboutMeLength) {
next(new Error('[[error:about-me-too-long, ' + meta.config.maximumAboutMeLength + ']]'));
} else {
next();
}
}
function isSignatureValid(next) { function isSignatureValid(next) {
if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) { if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) {
next(new Error('[[error:signature-too-long, ' + meta.config.maximumSignatureLength + ']]')); next(new Error('[[error:signature-too-long, ' + meta.config.maximumSignatureLength + ']]'));
@ -92,7 +100,7 @@ module.exports = function(User) {
}); });
} }
async.series([isSignatureValid, isEmailAvailable, isUsernameAvailable], function(err, results) { async.series([isAboutMeValid, isSignatureValid, isEmailAvailable, isUsernameAvailable], function(err) {
if (err) { if (err) {
return callback(err); return callback(err);
} }

@ -132,6 +132,10 @@
<label>Minimum Password Length</label> <label>Minimum Password Length</label>
<input type="text" class="form-control" value="6" data-field="minimumPasswordLength"> <input type="text" class="form-control" value="6" data-field="minimumPasswordLength">
</div> </div>
<div class="form-group">
<label>Maximum About Me Length</label>
<input type="text" class="form-control" value="500" data-field="maximumAboutMeLength">
</div>
<div class="form-group"> <div class="form-group">
<label>Forum Terms of Use <small>(Leave blank to disable)</small></label> <label>Forum Terms of Use <small>(Leave blank to disable)</small></label>
<textarea class="form-control" data-field="termsOfUse"></textarea> <textarea class="form-control" data-field="termsOfUse"></textarea>

Loading…
Cancel
Save