Made work uneditable for non-authorized users
This commit is contained in:
parent
36bdcf145f
commit
583fbaa05a
@ -67,7 +67,10 @@ Template.registerHelper('myClasses', () => {
|
|||||||
var courses = Meteor.user().profile.classes;
|
var courses = Meteor.user().profile.classes;
|
||||||
for(var i = 0; i < courses.length; i++) {
|
for(var i = 0; i < courses.length; i++) {
|
||||||
found = classes.findOne({_id:courses[i]});
|
found = classes.findOne({_id:courses[i]});
|
||||||
|
|
||||||
|
if(found.admin === Meteor.userId()) found.box = " owned";
|
||||||
array.push(found);
|
array.push(found);
|
||||||
|
|
||||||
var thisWork = work.find({class: courses[i]}).fetch();
|
var thisWork = work.find({class: courses[i]}).fetch();
|
||||||
|
|
||||||
for(var j = 0; j < thisWork.length; j++) {
|
for(var j = 0; j < thisWork.length; j++) {
|
||||||
@ -75,7 +78,6 @@ Template.registerHelper('myClasses', () => {
|
|||||||
thisWork[j].typeColor = workColors[thisWork[j].type];
|
thisWork[j].typeColor = workColors[thisWork[j].type];
|
||||||
}
|
}
|
||||||
array[i].thisClassWork = thisWork;
|
array[i].thisClassWork = thisWork;
|
||||||
console.log(array);
|
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
@ -191,7 +193,9 @@ Template.main.helpers({
|
|||||||
} else {
|
} else {
|
||||||
if(Meteor.userId() === Session.get("currentWork").creator ||
|
if(Meteor.userId() === Session.get("currentWork").creator ||
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
classes.findOne({_id: Session.get("currentWork")._id}).moderators.indexOf(Meteor.userId()) !== -1
|
classes.findOne({_id: Session.get("currentWork")._id}).moderators.indexOf(Meteor.userId()) !== -1||
|
||||||
|
classes.findOne({_id: Session.get("currentWork")._id}).blockEdit.indexOf(Meteor.userId()) !== -1 ||
|
||||||
|
classes.findOne({_id: Session.get("currentWork")._id}).banned.indexOf(Meteor.userId()) !== -1
|
||||||
) return true;
|
) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,6 +303,13 @@ Template.main.events({
|
|||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
'click .change' (event) {
|
'click .change' (event) {
|
||||||
|
if(!(Meteor.userId() === Session.get("currentWork").creator ||
|
||||||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
|
classes.findOne({_id: Session.get("currentWork")._id}).moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
|
classes.findOne({_id: Session.get("currentWork")._id}).blockEdit.indexOf(Meteor.userId()) !== -1 ||
|
||||||
|
classes.findOne({_id: Session.get("currentWork")._id}).banned.indexOf(Meteor.userId()) !== -1
|
||||||
|
)) return;
|
||||||
|
|
||||||
var ele = event.target;
|
var ele = event.target;
|
||||||
var sessval = Session.get("modifying");
|
var sessval = Session.get("modifying");
|
||||||
if (ele.id !== sessval && sessval !== null) closeInput(sessval);
|
if (ele.id !== sessval && sessval !== null) closeInput(sessval);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user