add scope to server variables

This commit is contained in:
Yaman Qalieh 2016-08-29 21:13:35 -04:00
parent cb8c9025f4
commit 156fa11930

View File

@ -8,12 +8,12 @@ import {
// Defines who the admins are - not added // Defines who the admins are - not added
superadmins = [ var superadmins = [
"ybq987@gmail.com", "ybq987@gmail.com",
"ksjdragon@gmail.com" "ksjdragon@gmail.com"
]; ];
worktype = ["test", "quiz", "project", "normal", "other"]; var worktype = ["test", "quiz", "project", "normal", "other"];
var possiblelist = ["moderators", "banned"]; var possiblelist = ["moderators", "banned"];
// Adds roles to superadmins // Adds roles to superadmins
@ -45,7 +45,7 @@ Meteor.publish('classes', function() {
return classes.find(); return classes.find();
} else { } else {
// Return user classes (if private) and public classes. // Return user classes (if private) and public classes.
userclasses = Meteor.users.findOne(this.userId).profile.classes; var userclasses = Meteor.users.findOne(this.userId).profile.classes;
if (userclasses !== undefined) { if (userclasses !== undefined) {
return classes.find({ return classes.find({
$or: [{ $or: [{
@ -86,7 +86,7 @@ Meteor.publish('work', function() {
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) { if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
return work.find(); return work.find();
} else { } else {
userclasses = Meteor.users.findOne(this.userId).profile.classes; var userclasses = Meteor.users.findOne(this.userId).profile.classes;
if (userclasses !== undefined) { if (userclasses !== undefined) {
return work.find({ return work.find({
// Only return work of enrolled classes // Only return work of enrolled classes
@ -142,7 +142,7 @@ Meteor.methods({
//Generates private codes for classes - like google classroom //Generates private codes for classes - like google classroom
'genCode': function() { 'genCode': function() {
currcode = Math.random().toString(36).substr(2, 6); var currcode = Math.random().toString(36).substr(2, 6);
while (classes.findOne({ while (classes.findOne({
code: currcode code: currcode
}) !== undefined) { }) !== undefined) {
@ -430,11 +430,11 @@ Meteor.methods({
_id: workobject.class _id: workobject.class
}); });
var user = Meteor.userId(); var user = Meteor.userId();
foundsubs = currentclass.subscribers; var foundsubs = currentclass.subscribers;
if (typeof comment === "string" && comment.length <= 200 && if (typeof comment === "string" && comment.length <= 200 &&
foundsubs.indexOf(Meteor.userId()) != -1 && foundsubs.indexOf(Meteor.userId()) != -1 &&
currentclass.banned.indexOf(Meteor.userId()) === -1) { currentclass.banned.indexOf(Meteor.userId()) === -1) {
commentInfo = { var commentInfo = {
"comment":input[0], "comment":input[0],
"user":user, "user":user,
"date": new Date() "date": new Date()
@ -460,7 +460,7 @@ Meteor.methods({
_id: workobject.class _id: workobject.class
}); });
if (currentclass.subscribers.indexOf(Meteor.userId()) != -1 && ["confirmations", "reports", "done"].indexOf(input[1]) != -1) { if (currentclass.subscribers.indexOf(Meteor.userId()) != -1 && ["confirmations", "reports", "done"].indexOf(input[1]) != -1) {
userindex = workobject[input[1]].indexOf(Meteor.userId()); var userindex = workobject[input[1]].indexOf(Meteor.userId());
if (userindex === -1) { if (userindex === -1) {
workobject[input[1]] = workobject[input[1]].concat(Meteor.userId()); workobject[input[1]] = workobject[input[1]].concat(Meteor.userId());
if (input[1] === "confirmations" && if (input[1] === "confirmations" &&
@ -535,7 +535,7 @@ Meteor.methods({
} }
}, },
'createProfile': function(userId) { 'createProfile': function(userId) {
current = Meteor.users.findOne({ var current = Meteor.users.findOne({
_id: userId _id: userId
}).profile; }).profile;
current.classes = []; current.classes = [];
@ -559,7 +559,7 @@ Meteor.methods({
found !== null && found !== null &&
pass === found.code && pass === found.code &&
prof.classes.indexOf(change) === -1) { prof.classes.indexOf(change) === -1) {
foundsubs = found.subscribers; var foundsubs = found.subscribers;
classes.update({ classes.update({
_id: found._id _id: found._id
}, { }, {