mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	| @@ -23,6 +23,7 @@ define('coverPhoto', [ | |||||||
| 					units: 'percent' | 					units: 'percent' | ||||||
| 				}); | 				}); | ||||||
| 		}); | 		}); | ||||||
|  | 		coverEl.find('.remove').on('click', coverPhoto.remove); | ||||||
|  |  | ||||||
| 		coverEl | 		coverEl | ||||||
| 			.on('dragover', coverPhoto.onDragOver) | 			.on('dragover', coverPhoto.onDragOver) | ||||||
| @@ -79,5 +80,17 @@ define('coverPhoto', [ | |||||||
| 		}); | 		}); | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | 	coverPhoto.remove = function() { | ||||||
|  | 		socket.emit('user.removeCover', { | ||||||
|  | 			uid: ajaxify.data.uid | ||||||
|  | 		}, function(err) { | ||||||
|  | 			if (!err) { | ||||||
|  | 				ajaxify.refresh(); | ||||||
|  | 			} else { | ||||||
|  | 				app.alertError(err.message); | ||||||
|  | 			} | ||||||
|  | 		}); | ||||||
|  | 	}; | ||||||
|  |  | ||||||
| 	return coverPhoto; | 	return coverPhoto; | ||||||
| }); | }); | ||||||
| @@ -131,7 +131,7 @@ editController.uploadCoverPicture = function(req, res, next) { | |||||||
| 			return next(err); | 			return next(err); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		res.json([{url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]); | 		res.json([{ url: image.url }]); | ||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -37,6 +37,20 @@ module.exports = function(SocketUser) { | |||||||
| 		}); | 		}); | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | 	SocketUser.removeCover = function(socket, data, callback) { | ||||||
|  | 		if (!socket.uid) { | ||||||
|  | 			return callback(new Error('[[error:no-privileges]]')); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		user.isAdministrator(socket.uid, function(err, isAdmin) { | ||||||
|  | 			if (!isAdmin && data.uid !== socket.uid) { | ||||||
|  | 				return callback(new Error('[[error:no-privileges]]')); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			user.removeCoverPicture(data, callback); | ||||||
|  | 		}); | ||||||
|  | 	}; | ||||||
|  |  | ||||||
| 	function isAdminOrSelfAndPasswordMatch(uid, data, callback) { | 	function isAdminOrSelfAndPasswordMatch(uid, data, callback) { | ||||||
| 		async.parallel({ | 		async.parallel({ | ||||||
| 			isAdmin: async.apply(user.isAdministrator, uid), | 			isAdmin: async.apply(user.isAdministrator, uid), | ||||||
|   | |||||||
| @@ -13,7 +13,8 @@ var async = require('async'), | |||||||
| 	plugins = require('../plugins'), | 	plugins = require('../plugins'), | ||||||
| 	file = require('../file'), | 	file = require('../file'), | ||||||
| 	image = require('../image'), | 	image = require('../image'), | ||||||
| 	meta = require('../meta'); | 	meta = require('../meta'), | ||||||
|  | 	db = require('../database'); | ||||||
|  |  | ||||||
| module.exports = function(User) { | module.exports = function(User) { | ||||||
|  |  | ||||||
| @@ -198,4 +199,7 @@ module.exports = function(User) { | |||||||
| 		}); | 		}); | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | 	User.removeCoverPicture = function(data, callback) { | ||||||
|  | 		db.deleteObjectField('user:' + data.uid, 'cover:url', callback); | ||||||
|  | 	}; | ||||||
| }; | }; | ||||||
		Reference in New Issue
	
	Block a user