closes #2803, closes #2883

options.unescape was not used correctly
fix groups.update so it  doesnt overwrite data if some fields are not
passed in
v1.18.x
barisusakli 10 years ago
parent d2dae2d62f
commit 358f6f61f7

@ -226,9 +226,9 @@ var async = require('async'),
return callback(err);
}
results.base.name = !options.unescape ? validator.escape(results.base.name) : results.base.name;
results.base.description = options.unescape ? validator.escape(results.base.description) : results.base.description;
results.base.description = !options.unescape ? validator.escape(results.base.description) : results.base.description;
results.base.descriptionParsed = descriptionParsed;
results.base.userTitle = options.unescape ? validator.escape(results.base.userTitle) : results.base.userTitle;
results.base.userTitle = !options.unescape ? validator.escape(results.base.userTitle) : results.base.userTitle;
results.base.userTitleEnabled = results.base.userTitleEnabled ? !!parseInt(results.base.userTitleEnabled, 10) : true;
results.base.createtimeISO = utils.toISOString(results.base.createtime);
results.base.members = results.users.filter(Boolean);
@ -538,14 +538,26 @@ var async = require('async'),
}
var payload = {
userTitle: values.userTitle || '',
userTitleEnabled: values.userTitleEnabled === true ? '1' : '0',
description: values.description || '',
icon: values.icon || '',
labelColor: values.labelColor || '#000000',
hidden: values.hidden === true ? '1' : '0',
'private': values.private === false ? '0' : '1'
};
description: values.description || '',
icon: values.icon || '',
labelColor: values.labelColor || '#000000'
};
if (values.hasOwnProperty('userTitle')) {
payload.userTitle = values.userTitle || '';
}
if (values.hasOwnProperty('userTitleEnabled')) {
payload.userTitleEnabled = values.userTitleEnabled ? '1' : '0';
}
if (values.hasOwnProperty('hidden')) {
payload.hidden = values.hidden ? '1' : '0';
}
if (values.hasOwnProperty('private')) {
payload.private = values.private ? '1' : '0';
}
async.series([
async.apply(updatePrivacy, groupName, values.private),
@ -566,9 +578,15 @@ var async = require('async'),
};
function updatePrivacy(groupName, newValue, callback) {
// Grab the group's current privacy value
if (!newValue) {
return callback();
}
Groups.getGroupFields(groupName, ['private'], function(err, currentValue) {
currentValue = currentValue.private === '1'; // Now a Boolean
if (err) {
return callback(err);
}
currentValue = currentValue.private === '1';
if (currentValue !== newValue && currentValue === true) {
// Group is now public, so all pending users are automatically considered members

Loading…
Cancel
Save