Hey All,
I'm contemplating the best way to implement the conditional permissions i.e. Users and Teams are m-to-m. But each Team also has a 1-to-m "Leader" relationship with the User table as well.
For simplicity sake, let's say we have two permission levels, "User" and "Admin". Then lets say, only certain Team administration task i.e. group emails, can only be sent by that team's leader.
At the moment, every action that is specific to team leaders queries the database to check it the current user is the team leader (keeping in mind a user may lead many Teams). I personally don't like seeing "if($user->isLeader($team))" all over the place.
I have considered setting a list of teams lead by a user in the user session on login (ala phpBB) or using a symfony filter to do the same.
However, in the first approach, the data can become stale in the case where another user may change a team's leader. The second approach requires an extra database query on every page load.
Any better ideas? note: there are multiple app in the one project that need to share the same permission model (i.e. backend and api)