 # Server admin code
-
 isAdmin = (userId) -> userId? and Meteor.users.findOne(userId)?.admin
 
 # Only admin gets server facts

# Helper publish function to get users for experiments that have ended.
# Necessary to watch completed experiments.
Meteor.publish "tsGroupUsers", (groupId) ->
  return null unless isAdmin(@userId)
  sub = this
  exp = Experiments.findOne(groupId)
  return unless exp

# Admin users - needs to update if group updates
# Return all experiments unless in a group
Meteor.publish "tsAdminState", (groupId) ->
  return [] unless isAdmin(@userId)

  cursors = [ Meteor.users.find({}, userFindOptions) ]

