Node.js based forum software built for the modern web
fix image upload for other users
barisusakli356f1d38cbf2
diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.jsindex 9cadf9d5db..ed94cf4b57 100644--- a/public/src/client/account/edit.js+++ b/public/src/client/account/edit.js@@ -74,7 +74,10 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],function handleImageChange() {$('#changePictureBtn').on('click', function() {- socket.emit('user.getProfilePictures', function(err, pictures) {+ socket.emit('user.getProfilePictures', {uid: ajaxify.data.uid}, function(err, pictures) {+ if (err) {+ return app.alertError(err.message);+ }templates.parse('partials/modals/change_picture_modal', {pictures: pictures,uploaded: !!ajaxify.data.uploadedpicture@@ -115,13 +118,6 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],}})}- // if (uploadedPicture) {- // modal.find('#user-uploaded-picture').attr('src', uploadedPicture);- // }-- // modal.find('#uploaded-box').toggle(!!uploadedPicture);- // modal.find('#default-box .fa-check').toggle(currentPicture !== uploadedPicture);- // modal.find('#uploaded-box .fa-check').toggle(currentPicture === uploadedPicture);}function selectImageType() {@@ -141,40 +137,6 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],ajaxify.refresh();});}-- // var modal = $(html);- // modal.on('hidden.bs.modal', function() {- // modal.remove();- // });- // selectedImageType = '';- // updateImages();-- // modal.modal('show');-- // modal.find('#default-box').on('click', function() {- // selectImageType('default');- // });-- // modal.find('#uploaded-box').on('click', function() {- // selectImageType('uploaded');- // });-- // modal.find('#savePictureChangesBtn').on('click', function() {-- // modal.modal('hide');-- // if (!selectedImageType) {- // return;- // }- // changeUserPicture(selectedImageType, function(err) {- // if (err) {- // return app.alertError(err.message);- // }-- // updateHeader(selectedImageType === 'uploaded' ? uploadedPicture : '');- // ajaxify.refresh();- // });- // });});});});diff --git a/src/socket.io/user/picture.js b/src/socket.io/user/picture.jsindex 2615e3e8de..acc1107173 100644--- a/src/socket.io/user/picture.js+++ b/src/socket.io/user/picture.js@@ -100,12 +100,16 @@ module.exports = function(SocketUser) {};SocketUser.getProfilePictures = function(socket, data, callback) {+ if (!data || !data.uid) {+ return callback(new Error('[[error:invalid-data]]'));+ }+async.parallel({list: async.apply(plugins.fireHook, 'filter:user.listPictures', {- uid: socket.uid,+ uid: data.uid,pictures: []}),- uploaded: async.apply(user.getUserField, socket.uid, 'uploadedpicture')+ uploaded: async.apply(user.getUserField, data.uid, 'uploadedpicture')}, function(err, data) {if (err) {return callback(err);