From f16c37eeaf84a22ed27fbdbc929e5ddcc83f80b3 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 10 Feb 2015 11:17:25 -0500 Subject: [PATCH] #2692 --- public/src/client/groups/details.js | 13 +++++++++++++ src/socket.io/groups.js | 20 +++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index 09826fb673..b40957af8a 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -39,6 +39,19 @@ define('forum/groups/details', ['iconSelect', 'vendor/colorpicker/colorpicker', }); break; + case 'kick': + socket.emit('groups.kick', { + uid: uid, + groupName: ajaxify.variables.get('group_name') + }, function(err) { + if (!err) { + userRow.slideUp().remove(); + } else { + app.alertError(err.message); + } + }); + break; + case 'update': Details.update(); break; diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js index a99112eded..ba35e128c4 100644 --- a/src/socket.io/groups.js +++ b/src/socket.io/groups.js @@ -102,7 +102,7 @@ SocketGroups.reject = function(socket, data, callback) { }; SocketGroups.update = function(socket, data, callback) { - if(!data) { + if (!data) { return callback(new Error('[[error:invalid-data]]')); } @@ -130,7 +130,7 @@ SocketGroups.create = function(socket, data, callback) { }; SocketGroups.delete = function(socket, data, callback) { - if(!data) { + if (!data) { return callback(new Error('[[error:invalid-data]]')); } @@ -156,6 +156,20 @@ SocketGroups.search = function(socket, data, callback) { groups.search(data.query || '', data.options || {}, callback); }; +SocketGroups.kick = function(socket, data, callback) { + if (!data) { + return callback(new Error('[[error:invalid-data]]')); + } + + groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) { + if (!isOwner) { + return callback(new Error('[[error:no-privileges]]')); + } + + groups.leave(data.groupName, data.uid, callback); + }); +}; + SocketGroups.cover = {}; SocketGroups.cover.get = function(socket, data, callback) { @@ -163,7 +177,7 @@ SocketGroups.cover.get = function(socket, data, callback) { }; SocketGroups.cover.update = function(socket, data, callback) { - if(!data) { + if (!data) { return callback(new Error('[[error:invalid-data]]')); } else if (socket.uid === 0) { return callback(new Error('[[error:no-privileges]]'));