lila/app/controllers/ForumController.scala

40 lines
1.2 KiB
Scala
Raw Normal View History

2013-04-01 07:18:11 -06:00
package controllers
2012-05-26 08:20:59 -06:00
2017-01-15 05:26:08 -07:00
import play.api.mvc._
2014-04-18 03:51:19 -06:00
import lila.api.Context
2013-04-01 07:18:11 -06:00
import lila.app._
import lila.forum
2012-05-26 08:20:59 -06:00
2014-02-17 02:12:19 -07:00
private[controllers] trait ForumController extends forum.Granter { self: LilaController =>
2012-05-26 16:27:53 -06:00
2019-12-04 16:39:16 -07:00
protected def categApi = env.forum.categApi
protected def topicApi = env.forum.topicApi
2019-12-13 07:30:20 -07:00
protected def postApi = env.forum.postApi
protected def forms = env.forum.forms
2019-12-04 16:39:16 -07:00
protected def teamCache = env.team.cached
protected def userBelongsToTeam(teamId: String, userId: String): Fu[Boolean] =
2019-12-04 16:39:16 -07:00
env.team.api.belongsTo(teamId, userId)
2012-12-13 09:37:46 -07:00
protected def userOwnsTeam(teamId: String, userId: String): Fu[Boolean] =
env.team.api.leads(teamId, userId)
2019-12-13 07:30:20 -07:00
protected def CategGrantWrite[A <: Result](
categSlug: String
)(a: => Fu[A])(implicit ctx: Context): Fu[Result] =
isGrantedWrite(categSlug) flatMap { granted =>
if (granted) a
else fuccess(Forbidden("You cannot post to this category"))
}
2019-12-13 07:30:20 -07:00
protected def CategGrantMod[A <: Result](
categSlug: String
)(a: => Fu[A])(implicit ctx: Context): Fu[Result] =
2014-02-17 02:12:19 -07:00
isGrantedMod(categSlug) flatMap { granted =>
if (granted | isGranted(_.ModerateForum)) a
else fuccess(Forbidden("You cannot post to this category"))
}
2012-05-26 08:20:59 -06:00
}