|
|
@ -140,7 +140,6 @@ SocketUser.changePicture = function(socket, data, callback) {
|
|
|
|
if(err) {
|
|
|
|
if(err) {
|
|
|
|
return callback(err);
|
|
|
|
return callback(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -172,18 +171,48 @@ SocketUser.unfollow = function(socket, data, callback) {
|
|
|
|
|
|
|
|
|
|
|
|
SocketUser.getSettings = function(socket, data, callback) {
|
|
|
|
SocketUser.getSettings = function(socket, data, callback) {
|
|
|
|
if (socket.uid) {
|
|
|
|
if (socket.uid) {
|
|
|
|
user.getSettings(socket.uid, callback);
|
|
|
|
if (socket.uid === parseInt(data.uid, 10)) {
|
|
|
|
|
|
|
|
return user.getSettings(socket.uid, callback);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.isAdministrator(socket.uid, function(err, isAdmin) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isAdmin) {
|
|
|
|
|
|
|
|
return callback(new Error('[[error:no-privileges]]'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.getSettings(data.uid, callback);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SocketUser.saveSettings = function(socket, data, callback) {
|
|
|
|
SocketUser.saveSettings = function(socket, data, callback) {
|
|
|
|
if (socket.uid && data) {
|
|
|
|
if (!socket.uid || !data) {
|
|
|
|
user.saveSettings(socket.uid, data, callback);
|
|
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (socket.uid === parseInt(data.uid, 10)) {
|
|
|
|
|
|
|
|
return user.saveSettings(socket.uid, data.settings, callback);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.isAdministrator(socket.uid, function(err, isAdmin) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isAdmin) {
|
|
|
|
|
|
|
|
return callback(new Error('[[error:no-privileges]]'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.saveSettings(data.uid, data.settings, callback);
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SocketUser.setTopicSort = function(socket, sort, callback) {
|
|
|
|
SocketUser.setTopicSort = function(socket, sort, callback) {
|
|
|
|
if(socket.uid) {
|
|
|
|
if (socket.uid) {
|
|
|
|
user.setSetting(socket.uid, 'topicPostSort', sort, callback);
|
|
|
|
user.setSetting(socket.uid, 'topicPostSort', sort, callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|