protected static function load_article($permalink = null) { if (!$permalink) { $permalink = $_GET['permalink']; } $object = Article::find_by_permalink($permalink); if ($object) { if (Site::CurrentUser() && Site::CurrentUser()->isAdmin()) { return $object; } elseif (!$object->published || $object->publish_at > time()) { throw new Error404('Article has not been published'); } return $object; } else { throw new Error404('Unable to find the article'); } }