- add methods to get moderators and viewers

This commit is contained in:
Richard Alam 2013-07-04 18:00:51 +00:00
parent 944db497e2
commit 4324655bc3

View File

@ -15,10 +15,7 @@ class UsersModel {
}
def removeUser(userID: String):Unit = {
users.get(userID) match {
case Some(u) => users -= userID;
case None => // do nothing
}
if (hasUser(userID)) users -= userID
}
def hasUser(userID: String):Boolean = {
@ -30,24 +27,20 @@ class UsersModel {
}
def isModerator(userID: String):Boolean = {
var moderator = false
users.get(userID) match {
case Some(u) => {
moderator = (u.role == MODERATOR)
}
case None => moderator = false
}
var moderator = false
if (hasUser(userID)) {
val u = getUser(userID)
moderator = if (u.role == MODERATOR.toString()) true else false
}
moderator
}
def isPresenter(userID: String):Boolean = {
var presenter = false
users.get(userID) match {
case Some(u) => {
presenter = u.isPresenter
}
case None => presenter = false
}
if (hasUser(userID)) {
val u = getUser(userID)
presenter = u.presenter
}
presenter
}
@ -121,4 +114,20 @@ class UsersModel {
case None => // do nothing
}
}
def getModerators():Array[UserVO] = {
val mods = new ArrayBuffer[UserVO]()
users.values.foreach(u => {
if (u.role == MODERATOR) mods += u.toUserVO
})
mods.toArray
}
def getViewers():Array[UserVO] = {
val viewers = new ArrayBuffer[UserVO]()
users.values.foreach(u => {
if (u.role != MODERATOR) viewers += u.toUserVO
})
viewers.toArray
}
}