diff options
-rw-r--r-- | core/config/config.php | 7 | ||||
-rw-r--r-- | core/controllers/maintenance.php | 30 | ||||
-rw-r--r-- | core/helpers/core.php | 30 | ||||
-rw-r--r-- | core/hooks/init_gallery.php | 1 | ||||
-rw-r--r-- | core/libraries/Theme_View.php | 8 | ||||
-rw-r--r-- | themes/default/views/maintenance.html.php | 56 |
6 files changed, 132 insertions, 0 deletions
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 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Maintenance_Controller extends Controller { + function index() { + $album = ORM::factory("item", 1); + $v = new Theme_View("maintenance.html", "reset"); + $v->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 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class core_Core { + static function maintenance_mode() { + $maintenance_mode = Kohana::config("core.maintenance_mode", false, false); + + if (Router::$controller != "login" && !empty($maintenance_mode) && !user::active()->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) { diff --git a/themes/default/views/maintenance.html.php b/themes/default/views/maintenance.html.php new file mode 100644 index 00000000..fde3973d --- /dev/null +++ b/themes/default/views/maintenance.html.php @@ -0,0 +1,56 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tranisitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <title><?= $title ?></title> + <link rel="shortcut icon" href="<?= $theme->url("images/favicon.ico") ?>" type="image/x-icon" /> + <link rel="stylesheet" type="text/css" href="<?= url::file("lib/yui/reset-fonts-grids.css") ?>" + media="screen,print,projection" /> + <link rel="stylesheet" type="text/css" href="<?= url::file("lib/superfish/css/superfish.css") ?>" + media="screen" /> + <link rel="stylesheet" type="text/css" href="<?= url::file("lib/themeroller/ui.base.css") ?>" + media="screen,print,projection" /> + <link rel="stylesheet" type="text/css" href="<?= $theme->url("css/screen.css") ?>" + media="screen,print,projection" /> + <!--[if IE]> + <link rel="stylesheet" type="text/css" href="<?= $theme->url("css/fix-ie.css") ?>" + media="screen,print,projection" /> + <![endif]--> + <script src="<?= url::file("lib/jquery.js") ?>" type="text/javascript"></script> + <script src="<?= url::file("lib/jquery.form.js") ?>" type="text/javascript"></script> + <script src="<?= url::file("lib/jquery-ui.js") ?>" type="text/javascript"></script> + <script src="<?= url::file("lib/gallery.dialog.js") ?>" type="text/javascript"></script> + <script src="<?= url::file("lib/superfish/js/superfish.js") ?>" type="text/javascript"></script> + <script src="<?= $theme->url("js/jquery.scrollTo.js") ?>" type="text/javascript"></script> + <script src="<?= $theme->url("js/jquery.localscroll.js") ?>" type="text/javascript"></script> + <script src="<?= $theme->url("js/ui.init.js") ?>" type="text/javascript"></script> + <?= $theme->head() ?> + </head> + + <body> + <?= $theme->page_top() ?> + <div id="doc4" class="yui-t5 gView"> + <div id="hd"> + <?= $theme->site_status() ?> + <div id="gHeader"> + <?= $theme->display("header.html") ?> + </div> + </div> + <div id="bd"> + <div id="gContent" style="float:left"> + <ul id="gMessage"> + <li class="gWarning"><?= $content ?></li> + </ul> + </div> + </div> + <div id="ft"> + <div id="gFooter"> + <?= $theme->display("footer.html") ?> + </div> + </div> + </div> + <?= $theme->page_bottom() ?> + </body> +</html> |