v1.18.x
Julian Lam 10 years ago
parent d895ca6827
commit 72f28b7b38

@ -66,6 +66,7 @@
"group-already-exists": "Group already exists",
"group-name-change-not-allowed": "Group name change not allowed",
"group-already-member": "You are already part of this group",
"group-needs-owner": "This group requires at least one owner",
"post-already-deleted": "This post has already been deleted",
"post-already-restored": "This post has already been restored",

@ -34,7 +34,7 @@ define('forum/groups/details', ['iconSelect', 'vendor/colorpicker/colorpicker',
if (!err) {
ownerFlagEl.toggleClass('invisible');
} else {
app.alertError(err);
app.alertError(err.message);
}
});
break;

@ -659,8 +659,8 @@ var async = require('async'),
Groups.requestMembership = function(groupName, uid, callback) {
async.parallel({
exists: async.apply(Groups.isMember, uid, groupName),
isMember: async.apply(Groups.exists, groupName)
exists: async.apply(Groups.exists, groupName),
isMember: async.apply(Groups.isMember, uid, groupName)
}, function(err, checks) {
if (!checks.exists) {
return callback(new Error('[[error:no-group]]'));
@ -694,7 +694,12 @@ var async = require('async'),
Groups.leave = function(groupName, uid, callback) {
callback = callback || function() {};
db.sortedSetRemove('group:' + groupName + ':members', uid, function(err) {
var tasks = [
async.apply(db.sortedSetRemove, 'group:' + groupName + ':members', uid),
async.apply(db.setRemove, 'group:' + groupName + ':owners', uid)
];
async.parallel(tasks, function(err) {
if (err) {
return callback(err);
}
@ -891,7 +896,15 @@ var async = require('async'),
Groups.ownership.rescind = function(toUid, groupName, callback) {
// Note: No ownership checking is done here on purpose!
db.setRemove('group:' + groupName + ':owners', toUid, callback);
// If the owners set only contains one member, error out!
db.setCount('group:' + groupName + ':owners', function(err, numOwners) {
if (numOwners <= 1) {
return callback(new Error('[[error:group-needs-owner]]'));
}
db.setRemove('group:' + groupName + ':owners', toUid, callback);
});
};
Groups.search = function(query, options, callback) {

Loading…
Cancel
Save