v1.18.x
barisusakli 11 years ago
parent 016a98e7b1
commit c000e852b5

@ -32,6 +32,7 @@
"edit": "Edit", "edit": "Edit",
"uploaded_picture": "Uploaded Picture", "uploaded_picture": "Uploaded Picture",
"upload_new_picture": "Upload New Picture", "upload_new_picture": "Upload New Picture",
"upload_new_picture_from_url": "Upload New Picture From URL",
"current_password": "Current Password", "current_password": "Current Password",
"change_password": "Change Password", "change_password": "Change Password",
"change_password_error": "Invalid Password!", "change_password_error": "Invalid Password!",

@ -151,6 +151,16 @@ define('forum/account/edit', ['forum/account/header', 'uploader'], function(head
} }
function handleImageUpload() { function handleImageUpload() {
function onUploadComplete(urlOnServer) {
urlOnServer = urlOnServer + '?' + new Date().getTime();
$('#user-current-picture').attr('src', urlOnServer);
$('#user-uploaded-picture').attr('src', urlOnServer);
$('#user-header-picture').attr('src', urlOnServer);
uploadedPicture = urlOnServer;
}
$('#upload-picture-modal').on('hide', function() { $('#upload-picture-modal').on('hide', function() {
$('#userPhotoInput').val(''); $('#userPhotoInput').val('');
}); });
@ -159,15 +169,33 @@ define('forum/account/edit', ['forum/account/header', 'uploader'], function(head
$('#change-picture-modal').modal('hide'); $('#change-picture-modal').modal('hide');
uploader.open(config.relative_path + '/api/user/' + ajaxify.variables.get('userslug') + '/uploadpicture', {}, config.maximumProfileImageSize, function(imageUrlOnServer) { uploader.open(config.relative_path + '/api/user/' + ajaxify.variables.get('userslug') + '/uploadpicture', {}, config.maximumProfileImageSize, function(imageUrlOnServer) {
imageUrlOnServer = imageUrlOnServer + '?' + new Date().getTime(); onUploadComplete(imageUrlOnServer);
});
$('#user-current-picture').attr('src', imageUrlOnServer); return false;
$('#user-uploaded-picture').attr('src', imageUrlOnServer); });
$('#user-header-picture').attr('src', imageUrlOnServer);
uploadedPicture = imageUrlOnServer; $('#uploadFromUrlBtn').on('click', function() {
}); $('#change-picture-modal').modal('hide');
var uploadModal = $('#upload-picture-from-url-modal');
uploadModal.modal('show').removeClass('hide');
uploadModal.find('.upload-btn').on('click', function() {
var url = uploadModal.find('#uploadFromUrl').val();
if (!url) {
return;
}
socket.emit('user.uploadProfileImageFromUrl', url, function(err, imageUrlOnServer) {
if (err) {
return app.alertError(err.message);
}
onUploadComplete(imageUrlOnServer);
uploadModal.modal('hide');
});
return false;
});
return false; return false;
}); });
} }

@ -453,8 +453,8 @@ accountsController.uploadPicture = function (req, res, next) {
return res.json({error: err.message}); return res.json({error: err.message});
} }
user.setUserField(updateUid, 'uploadedpicture', image.url); user.setUserFields(updateUid, {uploadedpicture: image.url, picture: image.url});
user.setUserField(updateUid, 'picture', image.url);
res.json({ res.json({
path: image.url path: image.url
}); });

@ -186,6 +186,22 @@ SocketUser.changePicture = function(socket, data, callback) {
}); });
}; };
SocketUser.uploadProfileImageFromUrl = function(socket, url, callback) {
if (!socket.uid || !url) {
return;
}
plugins.fireHook('filter:uploadImage', {url: url}, function(err, image) {
if (err) {
return callback(err);
}
user.setUserFields(socket.uid, {uploadedpicture: image.url, picture: image.url}, function(err) {
callback(err, image.url);
});
});
}
SocketUser.follow = function(socket, data, callback) { SocketUser.follow = function(socket, data, callback) {
if (!socket.uid || !data) { if (!socket.uid || !data) {
return; return;

Loading…
Cancel
Save