filter:group.update

v1.18.x
Timothy Fike 9 years ago committed by GitHub
parent 58ab76d3c2
commit e112d284e5

@ -17,54 +17,63 @@ module.exports = function(Groups) {
return callback(err || new Error('[[error:no-group]]')); return callback(err || new Error('[[error:no-group]]'));
} }
var payload = { plugins.fireHook('filter:group.update', {
description: values.description || '', groupName: groupName,
icon: values.icon || '', values: values
labelColor: values.labelColor || '#000000' }, function(err) {
}; if (err) {
return callback(err);
if (values.hasOwnProperty('userTitle')) { }
payload.userTitle = values.userTitle || '';
}
if (values.hasOwnProperty('userTitleEnabled')) { var payload = {
payload.userTitleEnabled = values.userTitleEnabled ? '1' : '0'; description: values.description || '',
} icon: values.icon || '',
labelColor: values.labelColor || '#000000'
};
if (values.hasOwnProperty('hidden')) { if (values.hasOwnProperty('userTitle')) {
payload.hidden = values.hidden ? '1' : '0'; payload.userTitle = values.userTitle || '';
} }
if (values.hasOwnProperty('private')) { if (values.hasOwnProperty('userTitleEnabled')) {
payload.private = values.private ? '1' : '0'; payload.userTitleEnabled = values.userTitleEnabled ? '1' : '0';
} }
if (values.hasOwnProperty('disableJoinRequests')) { if (values.hasOwnProperty('hidden')) {
payload.disableJoinRequests = values.disableJoinRequests ? '1' : '0'; payload.hidden = values.hidden ? '1' : '0';
} }
async.series([ if (values.hasOwnProperty('private')) {
async.apply(checkNameChange, groupName, values.name), payload.private = values.private ? '1' : '0';
async.apply(updatePrivacy, groupName, values.private), }
function(next) {
if (values.hasOwnProperty('hidden')) { if (values.hasOwnProperty('disableJoinRequests')) {
updateVisibility(groupName, values.hidden, next); payload.disableJoinRequests = values.disableJoinRequests ? '1' : '0';
} else {
next();
}
},
async.apply(db.setObject, 'group:' + groupName, payload),
async.apply(renameGroup, groupName, values.name)
], function(err) {
if (err) {
return callback(err);
} }
plugins.fireHook('action:group.update', { async.series([
name: groupName, async.apply(checkNameChange, groupName, values.name),
values: values async.apply(updatePrivacy, groupName, values.private),
function(next) {
if (values.hasOwnProperty('hidden')) {
updateVisibility(groupName, values.hidden, next);
} else {
next();
}
},
async.apply(db.setObject, 'group:' + groupName, payload),
async.apply(renameGroup, groupName, values.name)
], function(err) {
if (err) {
return callback(err);
}
plugins.fireHook('action:group.update', {
name: groupName,
values: values
});
callback();
}); });
callback();
}); });
}); });
}; };

Loading…
Cancel
Save