mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-31 04:06:07 +02:00
closes #3741
This commit is contained in:
@@ -59,12 +59,13 @@ groupsController.get = function(req, res, callback) {
|
||||
if (!exists) {
|
||||
return callback();
|
||||
}
|
||||
groups.get(groupName, {uid: req.uid}, next);
|
||||
groups.get(groupName, {uid: req.uid, truncateUserList: true, userListCount: 20}, next);
|
||||
}
|
||||
], function(err, group) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
group.isOwner = true;
|
||||
res.render('admin/manage/group', {group: group});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var async = require('async');
|
||||
var groups = require('../../groups'),
|
||||
Groups = {};
|
||||
|
||||
@@ -20,7 +21,17 @@ Groups.join = function(socket, data, callback) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
groups.join(data.groupName, data.uid, callback);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
groups.isMember(data.uid, data.groupName, next);
|
||||
},
|
||||
function (isMember, next) {
|
||||
if (isMember) {
|
||||
return next(new Error('[[error:group-already-member]]'));
|
||||
}
|
||||
groups.join(data.groupName, data.uid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Groups.leave = function(socket, data, callback) {
|
||||
@@ -32,7 +43,17 @@ Groups.leave = function(socket, data, callback) {
|
||||
return callback(new Error('[[error:cant-remove-self-as-admin]]'));
|
||||
}
|
||||
|
||||
groups.leave(data.groupName, data.uid, callback);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
groups.isMember(data.uid, data.groupName, next);
|
||||
},
|
||||
function (isMember, next) {
|
||||
if (!isMember) {
|
||||
return next(new Error('[[error:group-not-member]]'));
|
||||
}
|
||||
groups.leave(data.groupName, data.uid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Groups.update = function(socket, data, callback) {
|
||||
|
||||
@@ -62,8 +62,11 @@ SocketGroups.leave = function(socket, data, callback) {
|
||||
|
||||
function isOwner(next) {
|
||||
return function (socket, data, callback) {
|
||||
groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) {
|
||||
if (err || !isOwner) {
|
||||
async.parallel({
|
||||
isAdmin: async.apply(user.isAdmin, socket.uid),
|
||||
isOwner: async.apply(groups.ownership.isOwner, socket.uid, data.groupName)
|
||||
}, function(err, results) {
|
||||
if (err || (!isOwner && !results.isAdmin)) {
|
||||
return callback(err || new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
next(socket, data, callback);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
waitSeconds: 3,
|
||||
urlArgs: "{cache-buster}",
|
||||
paths: {
|
||||
'forum': '../client',
|
||||
'admin': '../admin',
|
||||
'vendor': '../../vendor',
|
||||
'buzz': '../../vendor/buzz/buzz.min'
|
||||
|
||||
@@ -54,24 +54,20 @@
|
||||
<label for="add-member">Add User to Group</label>
|
||||
<input type="text" class="form-control" id="group-details-search" placeholder="Search Users" />
|
||||
<ul class="members user-list" id="group-details-search-results"></ul>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<label>Members</label>
|
||||
<p>Click on a user to remove them from the group</p>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-users"></i> [[groups:details.members]]</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul class="members current_members user-list">
|
||||
<!-- BEGIN group.members -->
|
||||
<li data-uid="{group.members.uid}">
|
||||
<img src="{group.members.picture}" />
|
||||
<span>{group.members.username}</span>
|
||||
</li>
|
||||
<!-- END group.members -->
|
||||
</ul>
|
||||
<!-- IMPORT partials/groups/memberlist.tpl -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user