diff options
-rw-r--r-- | modules/gallery/helpers/gallery.php | 16 | ||||
-rw-r--r-- | modules/gallery/hooks/init_gallery.php | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 3f83b23d..924ee76a 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -37,6 +37,22 @@ class gallery_Core { } /** + * If the gallery is only available to registered users and the user is not logged in, present + * the login page. + */ + static function private_gallery() { + if (Router::$controller != "login" && + Router::$controller != "combined" && + identity::active_user()->guest && + !access::user_can(identity::guest(), "view", item::root())) { + Session::instance()->set("continue_url", url::abs_current()); + Router::$controller = "login"; + Router::$controller_path = MODPATH . "gallery/controllers/login.php"; + Router::$method = "html"; + } + } + + /** * This function is called when the Gallery is fully initialized. We relay it to modules as the * "gallery_ready" event. Any module that wants to perform an action at the start of every * request should implement the <module>_event::gallery_ready() handler. diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php index 64e44b56..10a74733 100644 --- a/modules/gallery/hooks/init_gallery.php +++ b/modules/gallery/hooks/init_gallery.php @@ -38,6 +38,7 @@ Event::add("system.ready", array("module", "load_modules")); Event::add("system.ready", array("gallery", "ready")); Event::add("system.post_routing", array("url", "parse_url")); Event::add("system.post_routing", array("gallery", "maintenance_mode")); +Event::add("system.post_routing", array("gallery", "private_gallery")); Event::add("system.shutdown", array("gallery", "shutdown")); // @todo once we convert to Kohana 2.4 this doesn't have to be here |