Skip to content

Instantly share code, notes, and snippets.

@jawngee
Created July 16, 2009 06:45
Show Gist options
  • Save jawngee/148272 to your computer and use it in GitHub Desktop.
Save jawngee/148272 to your computer and use it in GitHub Desktop.
<?
class HasAccessScreen extends Screen
{
public function before($controller,$metadata,&$data)
{
// make sure we have a valid user id from current session
if (!$uid=$controller->session->id)
throw new InvalidParametersException();
// fetch the forum ID
if (!$id=$controller->request->input->get_num($metadata->key))
throw new NotFoundException();
// find the forum model in the database
$forum=filter($metadata->to)->
->id->equals($id)
->owner_id->equals($uid)
->first();
// no forum, no love!
if (!$forum)
throw new NotFoundException();
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment