From 197e61a5d01fd5836a3455aedca6601474125d9a Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 9 Apr 2014 21:26:37 -0400 Subject: [PATCH] admin js language keys --- public/language/en_GB/error.json | 4 +++- src/socket.io/admin.js | 35 +++++++++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.json index a8ab3f574c..25cfd06ea4 100644 --- a/public/language/en_GB/error.json +++ b/public/language/en_GB/error.json @@ -21,5 +21,7 @@ "cant-vote-self-post": "You cannot vote for your own post", "already-favourited": "You already favourited this post", - "already-unfavourited": "You alread unfavourited this post" + "already-unfavourited": "You alread unfavourited this post", + + "cant-ban-other-admins": "You can't ban other admins!" } \ No newline at end of file diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index 5888fd636d..dc0b248ae9 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -79,7 +79,7 @@ SocketAdmin.user.removeAdmin = function(socket, theirid, callback) { SocketAdmin.user.createUser = function(socket, userData, callback) { if (!userData) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } user.create(userData, callback); }; @@ -87,7 +87,7 @@ SocketAdmin.user.createUser = function(socket, userData, callback) { SocketAdmin.user.banUser = function(socket, theirid, callback) { user.isAdministrator(theirid, function(err, isAdmin) { if (err || isAdmin) { - return callback(err || new Error('You can\'t ban other admins!')); + return callback(err || new Error('[[error:cant-ban-other-admins]]')); } user.ban(theirid, function(err) { @@ -137,6 +137,10 @@ SocketAdmin.user.search = function(socket, username, callback) { }); } + if (err) { + return callback(err); + } + async.each(data.users, isAdmin, function(err) { callback(err, data); }); @@ -146,7 +150,7 @@ SocketAdmin.user.search = function(socket, username, callback) { /* Categories */ SocketAdmin.categories.create = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } categories.create(data, callback); @@ -154,7 +158,7 @@ SocketAdmin.categories.create = function(socket, data, callback) { SocketAdmin.categories.update = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } categories.update(data, callback); @@ -162,7 +166,7 @@ SocketAdmin.categories.update = function(socket, data, callback) { SocketAdmin.categories.search = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } var username = data.username, @@ -184,7 +188,7 @@ SocketAdmin.categories.search = function(socket, data, callback) { SocketAdmin.categories.setPrivilege = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } var cid = data.cid, @@ -248,15 +252,14 @@ SocketAdmin.categories.getPrivilegeSettings = function(socket, cid, callback) { callback(null, { "+r": data['+r'].members, "+w": data['+w'].members, - "mods": data['mods'].members + "mods": data.mods.members }); }); }; SocketAdmin.categories.setGroupPrivilege = function(socket, data, callback) { - if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } if (data.set) { @@ -295,7 +298,7 @@ SocketAdmin.themes.getInstalled = function(socket, data, callback) { SocketAdmin.themes.set = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } widgets.reset(function(err) { @@ -315,7 +318,7 @@ SocketAdmin.plugins.toggle = function(socket, plugin_id) { SocketAdmin.widgets.set = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } widgets.setArea(data, callback); @@ -328,7 +331,7 @@ SocketAdmin.config.get = function(socket, data, callback) { SocketAdmin.config.set = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } meta.configs.set(data.key, data.value, function(err) { @@ -354,7 +357,7 @@ SocketAdmin.config.remove = function(socket, key) { /* Groups */ SocketAdmin.groups.create = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } groups.create(data.name, data.description, function(err, groupObj) { @@ -376,7 +379,7 @@ SocketAdmin.groups.get = function(socket, groupName, callback) { SocketAdmin.groups.join = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } groups.join(data.groupName, data.uid, callback); @@ -384,7 +387,7 @@ SocketAdmin.groups.join = function(socket, data, callback) { SocketAdmin.groups.leave = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } groups.leave(data.groupName, data.uid, callback); @@ -392,7 +395,7 @@ SocketAdmin.groups.leave = function(socket, data, callback) { SocketAdmin.groups.update = function(socket, data, callback) { if(!data) { - return callback(new Error('invalid data')); + return callback(new Error('[[error:invalid-data]]')); } groups.update(data.groupName, data.values, function(err) {