Node.js based forum software built for the modern web
closes #3130
barisusakli2880a77a9fb6
diff --git a/public/language/en_GB/global.json b/public/language/en_GB/global.jsonindex 92ef56998f..6fb6c8bc77 100644--- a/public/language/en_GB/global.json+++ b/public/language/en_GB/global.json@@ -64,6 +64,7 @@"reputation": "Reputation","read_more": "read more",+ "more": "More","posted_ago_by_guest": "posted %1 by Guest","posted_ago_by": "posted %1 by %2",diff --git a/public/language/en_GB/groups.json b/public/language/en_GB/groups.jsonindex 644bd6a4cb..d6a5ed6b6e 100644--- a/public/language/en_GB/groups.json+++ b/public/language/en_GB/groups.json@@ -7,6 +7,8 @@"pending.accept": "Accept","pending.reject": "Reject",+ "pending.accept_all": "Accept All",+ "pending.reject_all": "Reject All","cover-instructions": "Drag and Drop a photo, drag to position, and hit <strong>Save</strong>","cover-change": "Change",diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.jsindex 1a2742fb6b..1f7bd3f2df 100644--- a/public/src/client/groups/details.js+++ b/public/src/client/groups/details.js@@ -66,6 +66,8 @@ define('forum/groups/details', ['iconSelect', 'components', 'vendor/colorpicker/case 'reject':case 'acceptInvite':case 'rejectInvite':+ case 'acceptAll':+ case 'rejectAll':socket.emit('groups.' + action, {toUid: uid,groupName: ajaxify.variables.get('group_name')diff --git a/src/groups/membership.js b/src/groups/membership.jsindex 8c2ef23f31..6dbcbdb653 100644--- a/src/groups/membership.js+++ b/src/groups/membership.js@@ -337,4 +337,11 @@ module.exports = function(Groups) {}db.isSetMember('group:' + groupName + ':pending', uid, callback);};++ Groups.getPending = function(groupName, callback) {+ if (!groupName) {+ return callback(null, []);+ }+ db.getSetMembers('group:' + groupName + ':pending', callback);+ };};diff --git a/src/socket.io/groups.js b/src/socket.io/groups.jsindex ed058df7cb..d965a8d0f5 100644--- a/src/socket.io/groups.js+++ b/src/socket.io/groups.js@@ -102,6 +102,37 @@ SocketGroups.reject = function(socket, data, callback) {});};+SocketGroups.acceptAll = function(socket, data, callback) {+ acceptRejectAll('accept', socket, data, callback);+};++SocketGroups.rejectAll = function(socket, data, callback) {+ acceptRejectAll('reject', socket, data, callback);+};++function acceptRejectAll(type, socket, data, callback) {+ if (!data) {+ return callback(new Error('[[error:invalid-data]]'));+ }++ groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) {+ if (err || !isOwner) {+ return callback(err || new Error('[[error:no-privileges]]'));+ }+ async.waterfall([+ function(next) {+ groups.getPending(data.groupName, next);+ },+ function(uids, next) {+ var method = type === 'accept' ? groups.acceptMembership : groups.rejectMembership;+ async.each(uids, function(uid, next) {+ method(data.groupName, uid, next);+ }, next);+ }+ ], callback);+ });+}+SocketGroups.acceptInvite = function(socket, data, callback) {if (!data) {return callback(new Error('[[error:invalid-data]]'));