Small fixes for effects, health, permissions and formatting

This commit is contained in:
Thaum
2015-04-07 13:32:35 +00:00
parent 2fac76f702
commit 974c4fe706
8 changed files with 118 additions and 103 deletions

View File

@@ -16,9 +16,16 @@ CHARACTER_SUBSCHEMA_ALLOW = {
};
CHARACTER_SUBSCHEMA_DENY = {
update: function (userId, docs, fields, modifier) {
// can't change character
return _.contains(fields, 'charId');
update: function (userId, doc, fields, modifier) {
if(modifier && modifier.$set && modifier.$set.charId){
var id1 = doc.charId;
var char1 = Characters.findOne( id1, { fields: {owner: 1, writers: 1} } ) || {};
var char1Allowed = ( userId && char1.owner === userId || _.contains(char1.writers, userId) );
var id2 = modifier.$set.charId;
var char2 = Characters.findOne( id2, { fields: {owner: 1, writers: 1} } ) || {};
var char2Allowed = ( userId && char1.owner === userId || _.contains(char1.writers, userId) );
return (!char1Allowed || !char2Allowed);
}
},
fetch: ["charId"]
};

View File

@@ -130,7 +130,7 @@ var checkPermission = function(userId, charId){
var cascadeSoftRemove = function(id, removedWithId){
_.each(childCollections, function(treeCollection){
treeCollection.update({"parent.id": id}, {$set: {removed: true, removedWith: removedWithId}});
treeCollection.update({"parent.id": id}, {$set: {removed: true, removedWith: removedWithId}}, {multi: true});
treeCollection.find({"parent.id": id}).forEach(function(doc){
cascadeSoftRemove(doc._id, removedWithId);
});
@@ -158,7 +158,7 @@ Meteor.methods({
var collection = Mongo.Collection.get(collectionName);
collection.restore(id);
_.each(childCollections, function(treeCollection){
treeCollection.update({removedWith: id, removed: true}, { $unset: {removed: true, removedWith: ""} });
treeCollection.update({removedWith: id, removed: true}, { $unset: {removed: true, removedWith: ""} }, {multi: true});
});
},
updateChildren: function (parent, modifier, limitToInheritance) {