|
|
|
@ -193,8 +193,10 @@ var async = require('async'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, function (err, results) {
|
|
|
|
|
if (err || !results.base) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
} else if (!results.base) {
|
|
|
|
|
return callback(new Error('[[error:no-group]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default image
|
|
|
|
@ -224,6 +226,18 @@ var async = require('async'),
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Groups.getByGroupslug = function(slug, options, callback) {
|
|
|
|
|
db.getObjectField('groupslug:groupname', slug, function(err, groupName) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
} else if (!groupName) {
|
|
|
|
|
return callback(new Error('[[error:no-group]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Groups.get.call(Groups, groupName, options, callback);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Groups.getGroupFields = function(groupName, fields, callback) {
|
|
|
|
|
db.getObjectFields('group:' + groupName, fields, callback);
|
|
|
|
|
};
|
|
|
|
@ -413,8 +427,10 @@ var async = require('async'),
|
|
|
|
|
return callback(new Error('[[error:group-already-exists]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var groupData = {
|
|
|
|
|
var slug = utils.slugify(data.name),
|
|
|
|
|
groupData = {
|
|
|
|
|
name: data.name,
|
|
|
|
|
slug: slug,
|
|
|
|
|
userTitle: data.name,
|
|
|
|
|
description: data.description || '',
|
|
|
|
|
deleted: '0',
|
|
|
|
@ -432,6 +448,10 @@ var async = require('async'),
|
|
|
|
|
tasks.push(async.apply(db.setAdd, 'group:' + data.name + ':members', data.ownerUid));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data.hidden) {
|
|
|
|
|
tasks.push(async.apply(db.setObjectField, 'groupslug:groupname', slug, data.name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.parallel(tasks, function(err) {
|
|
|
|
|
if (!err) {
|
|
|
|
|
plugins.fireHook('action:group.create', groupData);
|
|
|
|
@ -567,6 +587,7 @@ var async = require('async'),
|
|
|
|
|
async.apply(db.delete, 'group:' + groupName + ':members'),
|
|
|
|
|
async.apply(db.delete, 'group:' + groupName + ':pending'),
|
|
|
|
|
async.apply(db.delete, 'group:' + groupName + ':owners'),
|
|
|
|
|
async.apply(db.deleteObjectField, 'groupslug:groupname', utils.slugify(groupName)),
|
|
|
|
|
function(next) {
|
|
|
|
|
db.getSetMembers('groups', function(err, groups) {
|
|
|
|
|
if (err) {
|
|
|
|
@ -578,7 +599,7 @@ var async = require('async'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Groups.join = function(groupName, uid, callback) {
|
|
|
|
|