From 7786bb09d32570d9be33727a3fe4fb460fcceeaf Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 5 Mar 2009 00:32:33 +0000 Subject: Implement a Maintenance mode as per ticket: #15 --- core/config/config.php | 7 +++++++ core/controllers/maintenance.php | 30 ++++++++++++++++++++++++++++++ core/helpers/core.php | 30 ++++++++++++++++++++++++++++++ core/hooks/init_gallery.php | 1 + core/libraries/Theme_View.php | 8 ++++++++ 5 files changed, 76 insertions(+) create mode 100644 core/controllers/maintenance.php create mode 100644 core/helpers/core.php (limited to 'core') diff --git a/core/config/config.php b/core/config/config.php index 3bdb70c1..d120b24b 100644 --- a/core/config/config.php +++ b/core/config/config.php @@ -126,3 +126,10 @@ if (TEST_MODE) { array(MODPATH . 'gallery_unit_test', MODPATH . 'unit_test')); } + +/** + * Setting the maintenance_mode to block all non administrative access. In + * this mode a user can attempt to logon, but will be unable to access anything. + * The application will be have normally if an adminstrator logs on. + */ +//$config["maintenance_mode"] = true; diff --git a/core/controllers/maintenance.php b/core/controllers/maintenance.php new file mode 100644 index 00000000..908e90b5 --- /dev/null +++ b/core/controllers/maintenance.php @@ -0,0 +1,30 @@ +title = t("%title Unavailable", array("title" => $album->title)); + $v->content = t("%title is currently unavailable as it is undergoing maintenance", + array("title" => $album->title)); + + print $v; + } +} \ No newline at end of file diff --git a/core/helpers/core.php b/core/helpers/core.php new file mode 100644 index 00000000..5e5a12a7 --- /dev/null +++ b/core/helpers/core.php @@ -0,0 +1,30 @@ +admin) { + Router::$controller = "maintenance"; + Router::$controller_path = APPPATH . "controllers/maintenance.php"; + Router::$method = "index"; + } + } +} \ No newline at end of file diff --git a/core/hooks/init_gallery.php b/core/hooks/init_gallery.php index 014c29ea..13c61256 100644 --- a/core/hooks/init_gallery.php +++ b/core/hooks/init_gallery.php @@ -22,6 +22,7 @@ Event::add("system.post_routing", array("theme", "load_themes")); Event::add("system.ready", array("module", "load_modules")); Event::add("system.post_routing", array("url", "parse_url")); Event::add("system.shutdown", array("module", "shutdown")); +Event::add("system.post_routing", array("core", "maintenance_mode")); // Override the cookie if we have a session id in the URL. // @todo This should probably be an event callback diff --git a/core/libraries/Theme_View.php b/core/libraries/Theme_View.php index 1f8ca559..ea2a17f9 100644 --- a/core/libraries/Theme_View.php +++ b/core/libraries/Theme_View.php @@ -39,6 +39,14 @@ class Theme_View_Core extends View { $this->set_global('theme', $this); $this->set_global('user', user::active()); $this->set_global("page_type", $page_type); + + $maintenance_mode = Kohana::config("core.maintenance_mode", false, false); + if (!empty($maintenance_mode)) { + $album = ORM::factory("item", 1); + message::warning(t("%title is currently unavailable as it is undergoing maintenance", + array("title" => $album->title))); + } + } public function url($path, $absolute_url=false) { -- cgit v1.2.3