From 2a86446249c4782287e1e6e472f422b851c2fb47 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Sep 2010 00:50:02 -0700 Subject: Handle the case of a completely private Gallery separately and just put up a login page, very similar to the way that the maintenance mode login page works. Fixes ticket #1056. --- modules/gallery/helpers/gallery.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'modules/gallery/helpers/gallery.php') 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 @@ -36,6 +36,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 -- cgit v1.2.3 From 32d18920680ee63dc75c3a2b710ef805b31c127c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Sep 2010 22:53:06 -0700 Subject: Follow on to 2a86446249c4782287e1e6e472f422b851c2fb47; fix a bug where guest access to admin pages fails because we try to go to the login page but you can't do that from the admin theme. Thanks to mamouneyya for catching this. http://github.com/gallery/gallery3/commit/2a86446249c4782287e1e6e472f422b851c2fb47 --- modules/gallery/helpers/gallery.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'modules/gallery/helpers/gallery.php') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 924ee76a..9430231c 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -45,10 +45,17 @@ class gallery_Core { 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"; + if (Router::$controller == "admin") { + // At this point we're in the admin theme and it doesn't have a themed login page, so + // we can't just swap in the login controller and have it work. So redirect back to the + // root item where we'll run this code again with the site theme. + url::redirect(item::root()->abs_url()); + } else { + Session::instance()->set("continue_url", url::abs_current()); + Router::$controller = "login"; + Router::$controller_path = MODPATH . "gallery/controllers/login.php"; + Router::$method = "html"; + } } } -- cgit v1.2.3 From b08bf26d2db6c78315ef3ddfc2e0191923ecfa42 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 12 Sep 2010 14:34:49 -0700 Subject: Ignore the private gallery settings if we're in the cli SAPI. It breaks the upgrader. Fixes #1361, thanks to Romain LE DISEZ. --- modules/gallery/helpers/gallery.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers/gallery.php') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 9430231c..ca8c92c9 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -44,7 +44,8 @@ class gallery_Core { if (Router::$controller != "login" && Router::$controller != "combined" && identity::active_user()->guest && - !access::user_can(identity::guest(), "view", item::root())) { + !access::user_can(identity::guest(), "view", item::root()) && + php_sapi_name() != "cli") { if (Router::$controller == "admin") { // At this point we're in the admin theme and it doesn't have a themed login page, so // we can't just swap in the login controller and have it work. So redirect back to the -- cgit v1.2.3