mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	closed #2695
This commit is contained in:
		| @@ -19,14 +19,14 @@ module.exports = function(privileges) { | ||||
| 			labels: function(next) { | ||||
| 				async.parallel({ | ||||
| 					users: async.apply(plugins.fireHook, 'filter:privileges.list_human', | ||||
| 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics', 'Moderator'].map(function(name) { | ||||
| 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics', 'Moderate'].map(function(name) { | ||||
| 							return { | ||||
| 								name: name | ||||
| 							}; | ||||
| 						}) | ||||
| 					), | ||||
| 					groups: async.apply(plugins.fireHook, 'filter:privileges.groups.list_human', | ||||
| 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics'].map(function(name) { | ||||
| 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics', 'Moderate'].map(function(name) { | ||||
| 							return { | ||||
| 								name: name | ||||
| 							}; | ||||
| @@ -73,7 +73,7 @@ module.exports = function(privileges) { | ||||
| 				var privileges; | ||||
| 				async.waterfall([ | ||||
| 					async.apply(plugins.fireHook, 'filter:privileges.groups.list', [ | ||||
| 						'groups:find', 'groups:read', 'groups:topics:create', 'groups:topics:reply' | ||||
| 						'groups:find', 'groups:read', 'groups:topics:create', 'groups:topics:reply', 'groups:moderate' | ||||
| 					]), | ||||
| 					function(privs, next) { | ||||
| 						privileges = privs; | ||||
|   | ||||
							
								
								
									
										36
									
								
								src/user.js
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								src/user.js
									
									
									
									
									
								
							| @@ -415,15 +415,25 @@ var	async = require('async'), | ||||
| 			}); | ||||
|  | ||||
| 			var groupNames = uniqueCids.map(function(cid) { | ||||
| 				return 'cid:' + cid + ':privileges:mods'; | ||||
| 			}); | ||||
| 					return 'cid:' + cid + ':privileges:mods';	// At some point we should *probably* change this to "moderate" as well | ||||
| 				}), | ||||
| 				groupListNames = uniqueCids.map(function(cid) { | ||||
| 					return 'cid:' + cid + ':privileges:groups:moderate'; | ||||
| 				}); | ||||
|  | ||||
| 			groups.isMemberOfGroups(uid, groupNames, function(err, isMembers) { | ||||
| 			async.parallel({ | ||||
| 				user: async.apply(groups.isMemberOfGroups, uid, groupNames), | ||||
| 				group: async.apply(groups.isMemberOfGroupsList, uid, groupListNames) | ||||
| 			}, function(err, checks) { | ||||
| 				if (err) { | ||||
| 					return callback(err); | ||||
| 				} | ||||
|  | ||||
| 				var map = {}; | ||||
| 				var isMembers = checks.user.map(function(isMember, idx) { | ||||
| 						return isMember || checks.group[idx] | ||||
| 					}), | ||||
| 					map = {}; | ||||
|  | ||||
| 				uniqueCids.forEach(function(cid, index) { | ||||
| 					map[cid] = isMembers[index]; | ||||
| 				}); | ||||
| @@ -434,9 +444,23 @@ var	async = require('async'), | ||||
| 			}); | ||||
| 		} else { | ||||
| 			if (Array.isArray(uid)) { | ||||
| 				groups.isMembers(uid, 'cid:' + cid + ':privileges:mods', filterIsModerator); | ||||
| 				async.parallel([ | ||||
| 					async.apply(groups.isMembers, uid, 'cid:' + cid + ':privileges:mods'), | ||||
| 					async.apply(groups.isMembers, uid, 'cid:' + cid + ':privileges:groups:moderate') | ||||
| 				], function(err, checks) { | ||||
| 					var isModerator = checks[0].map(function(isMember, idx) { | ||||
| 							return isMember || checks[1][idx] | ||||
| 						}); | ||||
| 					filterIsModerator(null, isModerator); | ||||
| 				}); | ||||
| 			} else { | ||||
| 				groups.isMember(uid, 'cid:' + cid + ':privileges:mods', filterIsModerator); | ||||
| 				async.parallel([ | ||||
| 					async.apply(groups.isMember, uid, 'cid:' + cid + ':privileges:mods'), | ||||
| 					async.apply(groups.isMember, uid, 'cid:' + cid + ':privileges:groups:moderate') | ||||
| 				], function(err, checks) { | ||||
| 					var isModerator = checks[0] || checks[1]; | ||||
| 					filterIsModerator(null, isModerator); | ||||
| 				}); | ||||
| 			} | ||||
| 		} | ||||
| 	}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user