mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
privacy page
This commit is contained in:
@@ -11,14 +11,11 @@
|
||||
var postcount = $('#postcount');
|
||||
postcount.html(app.addCommas(postcount.html()));
|
||||
|
||||
var editLink = $('#editLink');
|
||||
var followBtn = $('#follow-btn');
|
||||
if(yourid === "0") {
|
||||
editLink.hide();
|
||||
followBtn.hide();
|
||||
}
|
||||
else if(yourid !== theirid) {
|
||||
editLink.hide();
|
||||
if(isFollowing)
|
||||
followBtn.hide();
|
||||
else
|
||||
|
||||
20
public/src/forum/accountheader.js
Normal file
20
public/src/forum/accountheader.js
Normal file
@@ -0,0 +1,20 @@
|
||||
(function() {
|
||||
var yourid = templates.get('yourid'),
|
||||
theirid = templates.get('theirid');
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var editLink = $('#editLink');
|
||||
var settingsLink = $('#settingsLink');
|
||||
|
||||
if(yourid === "0") {
|
||||
editLink.hide();
|
||||
settingsLink.hide();
|
||||
}
|
||||
else if(yourid !== theirid) {
|
||||
editLink.hide();
|
||||
settingsLink.hide();
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
@@ -2,5 +2,15 @@
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
$('#submitBtn').on('click', function() {
|
||||
|
||||
var settings = {
|
||||
showemail: $('#showemailCheckBox').is(':checked')?1:0
|
||||
};
|
||||
|
||||
socket.emit('api:user.saveSettings', settings);
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
@@ -9,12 +9,7 @@
|
||||
if(parseInt(followersCount, 10) === 0) {
|
||||
$('#no-followers-notice').show();
|
||||
}
|
||||
var editLink = $('#editLink');
|
||||
|
||||
if(yourid !== theirid) {
|
||||
editLink.hide();
|
||||
}
|
||||
|
||||
|
||||
$('.reputation').each(function(index, element) {
|
||||
$(element).html(app.addCommas($(element).html()));
|
||||
});
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
if(parseInt(followingCount, 10) === 0) {
|
||||
$('#no-following-notice').show();
|
||||
}
|
||||
var editLink = $('#editLink');
|
||||
|
||||
if(yourid !== theirid) {
|
||||
editLink.hide();
|
||||
$('.unfollow-btn').hide();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<h4>profile</h4>
|
||||
<div class="inline-block">
|
||||
<div class="account-bio-block">
|
||||
<span class="account-bio-label">email</span>
|
||||
<span class="account-bio-label">email</span><i class="icon-eye-close {emailClass}" title="Email hidden"></i>
|
||||
<span>{email}</span>
|
||||
<br/>
|
||||
|
||||
@@ -102,4 +102,5 @@
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
<input type="hidden" template-type="boolean" template-variable="isFollowing" value="{isFollowing}" />
|
||||
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/account.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/account.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
|
||||
@@ -171,4 +171,4 @@
|
||||
<input type="hidden" template-variable="gravatarpicture" value="{gravatarpicture}" />
|
||||
<input type="hidden" template-variable="uploadedpicture" value="{uploadedpicture}" />
|
||||
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/accountedit.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/accountedit.js"></script>
|
||||
|
||||
@@ -18,15 +18,17 @@
|
||||
<div class="span6">
|
||||
<h4>privacy</h4>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox"> Show my email
|
||||
<input id="showemailCheckBox" type="checkbox" {showemail}> Show my email
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="span6">
|
||||
span10
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<a id="submitBtn" href="#" class="btn btn-primary">Save changes</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/accountsettings.js"></script>
|
||||
@@ -42,4 +42,5 @@
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
<input type="hidden" template-variable="followersCount" value="{followersCount}" />
|
||||
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/followers.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/followers.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
|
||||
@@ -47,3 +47,4 @@
|
||||
<input type="hidden" template-variable="followingCount" value="{followingCount}" />
|
||||
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/following.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
|
||||
|
||||
@@ -97,7 +97,9 @@ var user = require('./../user.js'),
|
||||
|
||||
user.getUserField(req.user.uid, 'userslug', function(userslug) {
|
||||
if(req.params.userslug && userslug === req.params.userslug) {
|
||||
res.send(app.build_header(res) + app.create_route('users/'+req.params.userslug+'/settings','accountsettings') + templates['footer']);
|
||||
app.build_header({ req: req, res: res }, function(err, header) {
|
||||
res.send(header + app.create_route('users/'+req.params.userslug+'/settings','accountsettings') + templates['footer']);
|
||||
})
|
||||
} else {
|
||||
return res.redirect('/404');
|
||||
}
|
||||
@@ -124,24 +126,7 @@ var user = require('./../user.js'),
|
||||
return;
|
||||
}
|
||||
|
||||
user.getUserField(req.user.uid, 'uploadedpicture', function(oldpicture) {
|
||||
|
||||
if(!oldpicture) {
|
||||
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
|
||||
return;
|
||||
}
|
||||
|
||||
var absolutePath = path.join(global.configuration['ROOT_DIRECTORY'], global.nconf.get('upload_path'), path.basename(oldpicture));
|
||||
|
||||
fs.unlink(absolutePath, function(err) {
|
||||
if(err) {
|
||||
console.error('[%d] %s', Date.now(), + err);
|
||||
}
|
||||
|
||||
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
|
||||
|
||||
});
|
||||
});
|
||||
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
|
||||
});
|
||||
|
||||
function uploadUserPicture(uid, extension, tempPath, res) {
|
||||
@@ -254,6 +239,9 @@ var user = require('./../user.js'),
|
||||
getUserDataByUserSlug(userslug, callerUID, function(userData) {
|
||||
res.json(userData);
|
||||
});
|
||||
}
|
||||
else if (section === 'settings') {
|
||||
getSettings(req, res, callerUID);
|
||||
} else {
|
||||
getUserDataByUserSlug(userslug, callerUID, function(userData) {
|
||||
if(userData) {
|
||||
@@ -302,6 +290,32 @@ var user = require('./../user.js'),
|
||||
});
|
||||
}
|
||||
|
||||
function getSettings(req, res, callerUid) {
|
||||
|
||||
user.get_uid_by_userslug(req.params.userslug, function(uid) {
|
||||
if(!uid) {
|
||||
res.json(404, { error: 'User not found!' }) ;
|
||||
return;
|
||||
}
|
||||
uid = parseInt(uid, 10);
|
||||
if(uid !== callerUid || callerUid === "0") {
|
||||
res.json(403, { error: 'Not allowed!' });
|
||||
return;
|
||||
}
|
||||
user.getUserFields(uid, ['username','userslug','showemail'], function(userData) {
|
||||
if(userData) {
|
||||
if(userData.showemail && userData.showemail === "1")
|
||||
userData.showemail = "checked";
|
||||
else
|
||||
userData.showemail = "";
|
||||
res.json(userData);
|
||||
} else {
|
||||
res.json(404, { error: 'User not found!' }) ;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/api/users/:userslug?/:section?', api_method);
|
||||
app.get('/api/users-sort-posts', getUsersSortedByPosts);
|
||||
app.get('/api/users-sort-reputation', getUsersSortedByReputation);
|
||||
@@ -346,6 +360,8 @@ var user = require('./../user.js'),
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
uid = parseInt(uid, 10);
|
||||
|
||||
user.getUserData(uid, function(data) {
|
||||
if(data) {
|
||||
@@ -357,6 +373,19 @@ var user = require('./../user.js'),
|
||||
data.age = new Date().getFullYear() - new Date(data.birthday).getFullYear();
|
||||
}
|
||||
|
||||
function canSeeEmail() {
|
||||
return callerUID === uid || (data.email && (data.showemail && data.showemail === "1"));
|
||||
}
|
||||
|
||||
if(!canSeeEmail())
|
||||
data.email = "";
|
||||
|
||||
if(callerUID === uid && data.showemail === "0")
|
||||
data.emailClass = "";
|
||||
else
|
||||
data.emailClass = "hidden";
|
||||
|
||||
|
||||
data.uid = uid;
|
||||
data.yourid = callerUID;
|
||||
data.theirid = uid;
|
||||
|
||||
@@ -65,7 +65,8 @@ var utils = require('./../public/src/utils.js'),
|
||||
'reputation': 0,
|
||||
'postcount': 0,
|
||||
'lastposttime': 0,
|
||||
'administrator': (uid == 1) ? 1 : 0
|
||||
'administrator': (uid == 1) ? 1 : 0,
|
||||
'showemail': 0
|
||||
});
|
||||
|
||||
RDB.set('username:' + username + ':uid', uid);
|
||||
|
||||
@@ -313,6 +313,21 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('api:user.saveSettings', function(data) {
|
||||
if(uid) {
|
||||
user.setUserFields(uid, {
|
||||
showemail:data.showemail
|
||||
});
|
||||
|
||||
socket.emit('event:alert', {
|
||||
title: 'Saved',
|
||||
message: 'Settings saved!',
|
||||
type: 'success',
|
||||
timeout: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('api:topics.post', function(data) {
|
||||
topics.post(socket, uid, data.title, data.content, data.category_id, data.images);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user