I´m trying to build a private community site. Basicly what I would like to do is something like this for each page:
- Retrieve session if any
- Call a function that checks against the db if the user is allowed to view the specified page. Display error if not.
- Show content.
I could of course do this with an IF query on each page
IF( check_grants($username, $pagename) ) {
show content
} else {
show error
}
But this is what I want to escape, I don´t want a IF statement covering the entire page on all of my pages but rather just have a function at the top of the page and then only the private content in the rest of the page.
I have some ideas on how to do this but would appreciate input from more experienced coders on how to solve this kind of situation.
Thanx in advance.