web-beautify-js
This commit is contained in:
parent
6c2e98e6d0
commit
d5d2f842a3
@ -191,17 +191,46 @@ Meteor.methods({
|
|||||||
var month = ref.getMonth + 1;
|
var month = ref.getMonth + 1;
|
||||||
ref = new Date(ref.getFullYear() + "-" + month.toString() + "-" + ref.getDate()).getTime();
|
ref = new Date(ref.getFullYear() + "-" + month.toString() + "-" + ref.getDate()).getTime();
|
||||||
|
|
||||||
var currentclass = classes.findOne({_id: work.findOne({_id: workId}).class});
|
var currentclass = classes.findOne({
|
||||||
|
_id: work.findOne({
|
||||||
|
_id: workId
|
||||||
|
}).class
|
||||||
|
});
|
||||||
var authorized = currentclass.moderators.push(currentclass.admin);
|
var authorized = currentclass.moderators.push(currentclass.admin);
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||||
Meteor.update({_id: change._id}, {$set: change});
|
Meteor.update({
|
||||||
|
_id: change._id
|
||||||
|
}, {
|
||||||
|
$set: change
|
||||||
|
});
|
||||||
} else if (authorized.indexOf(Meteor.userId()) != -1) {
|
} else if (authorized.indexOf(Meteor.userId()) != -1) {
|
||||||
if (change.name.length <= 50 && worktype.indexOf(type) != -1) {
|
if (change.name.length <= 50 && worktype.indexOf(type) != -1) {
|
||||||
Meteor.update({_id: change._id}, {$set: {name: change.name, dueDate: change.dueDate, comments: change.comments, attachments: change.attachments, type: change.type}});
|
Meteor.update({
|
||||||
|
_id: change._id
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
name: change.name,
|
||||||
|
dueDate: change.dueDate,
|
||||||
|
comments: change.comments,
|
||||||
|
attachments: change.attachments,
|
||||||
|
type: change.type
|
||||||
}
|
}
|
||||||
} else if (Meteor.userId() === work.findOne({_id: change._id}).creator) {
|
});
|
||||||
|
}
|
||||||
|
} else if (Meteor.userId() === work.findOne({
|
||||||
|
_id: change._id
|
||||||
|
}).creator) {
|
||||||
if (change.name.length <= 50 && worktype.indexOf(type) != -1 && input.dueDate.getTime() >= ref) {
|
if (change.name.length <= 50 && worktype.indexOf(type) != -1 && input.dueDate.getTime() >= ref) {
|
||||||
Meteor.update({_id: change._id}, {$set: {name: change.name, dueDate: change.dueDate, attachments: change.attachments, type: change.type}});
|
Meteor.update({
|
||||||
|
_id: change._id
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
name: change.name,
|
||||||
|
dueDate: change.dueDate,
|
||||||
|
attachments: change.attachments,
|
||||||
|
type: change.type
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw "Unauthorized.";
|
throw "Unauthorized.";
|
||||||
@ -209,31 +238,52 @@ Meteor.methods({
|
|||||||
},
|
},
|
||||||
'addComment': function(input) {
|
'addComment': function(input) {
|
||||||
var comment = input[0];
|
var comment = input[0];
|
||||||
var workobject = work.findOne({_id: input[1]});
|
var workobject = work.findOne({
|
||||||
var currentclass = classes.findOne({_id: workobject.class});
|
_id: input[1]
|
||||||
|
});
|
||||||
|
var currentclass = classes.findOne({
|
||||||
|
_id: workobject.class
|
||||||
|
});
|
||||||
if (typeof comment === "string" && comment.length <= 200 &&
|
if (typeof comment === "string" && comment.length <= 200 &&
|
||||||
currentclass.subscribers.indexOf(Meteor.userId()) != -1 &&
|
currentclass.subscribers.indexOf(Meteor.userId()) != -1 &&
|
||||||
currentclass.blockEdit.indexOf(Meteor.userId()) === -1) {
|
currentclass.blockEdit.indexOf(Meteor.userId()) === -1) {
|
||||||
var comments = workobject.comments.push(comment);
|
var comments = workobject.comments.push(comment);
|
||||||
work.update({_id: input[1]}, {$set: {comments: comments}});
|
work.update({
|
||||||
|
_id: input[1]
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
comments: comments
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'toggleWork': function(input) {
|
'toggleWork': function(input) {
|
||||||
var workobject = work.findOne({_id: input[0]});
|
var workobject = work.findOne({
|
||||||
var currentclass = classes.findOne({_id: workobject.class});
|
_id: input[0]
|
||||||
if (currentclass.subscribers.indexOf(Meteor.userId()) != -1 &&
|
});
|
||||||
["confirmations", "reports", "done"].indexOf(input[1]) != -1) {
|
var currentclass = classes.findOne({
|
||||||
|
_id: workobject.class
|
||||||
|
});
|
||||||
|
if (currentclass.subscribers.indexOf(Meteor.userId()) != -1 && ["confirmations", "reports", "done"].indexOf(input[1]) != -1) {
|
||||||
userindex = workobject[input[1]].indexOf(Meteor.userId());
|
userindex = workobject[input[1]].indexOf(Meteor.userId());
|
||||||
if (userindex === -1) {
|
if (userindex === -1) {
|
||||||
workobject[input[1]] = workobject[input[1]].push(Meteor.userId());
|
workobject[input[1]] = workobject[input[1]].push(Meteor.userId());
|
||||||
} else {
|
} else {
|
||||||
workobject[input[1]] = workobject[input[1]].splice(userindex, 1);
|
workobject[input[1]] = workobject[input[1]].splice(userindex, 1);
|
||||||
}
|
}
|
||||||
work.update({_id: input[1]}, {$set: workobject});
|
work.update({
|
||||||
|
_id: input[1]
|
||||||
|
}, {
|
||||||
|
$set: workobject
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'deleteWork': function(workId) {
|
'deleteWork': function(workId) {
|
||||||
var currentclass = classes.findOne({_id: work.findOne({_id: workId}).class});
|
var currentclass = classes.findOne({
|
||||||
|
_id: work.findOne({
|
||||||
|
_id: workId
|
||||||
|
}).class
|
||||||
|
});
|
||||||
var authorized = currentclass.moderators.push(currentclass.admin);
|
var authorized = currentclass.moderators.push(currentclass.admin);
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
authorized.indexOf(Meteor.userId()) != -1) {
|
authorized.indexOf(Meteor.userId()) != -1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user