From 39e8e8b7333c0e3d4906bb5f5a6a0563a7a92d64 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 30 Jan 2012 02:24:17 +0000 Subject: [PATCH] downtime -> simpleext --- contrib/downtime/main.php | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/contrib/downtime/main.php b/contrib/downtime/main.php index 5dc57690..8c9ced34 100644 --- a/contrib/downtime/main.php +++ b/contrib/downtime/main.php @@ -11,31 +11,26 @@ * message specified in the box. */ -class Downtime implements Extension { - var $theme; - +class Downtime extends SimpleExtension { public function get_priority() {return 10;} - public function receive_event(Event $event) { - global $config, $database, $page, $user; - if(is_null($this->theme)) $this->theme = get_theme_object($this); + public function onSetupBuilding($event) { + $sb = new SetupBlock("Downtime"); + $sb->add_bool_option("downtime", "Disable non-admin access: "); + $sb->add_longtext_option("downtime_message", "
"); + $event->panel->add_block($sb); + } - if($event instanceof SetupBuildingEvent) { - $sb = new SetupBlock("Downtime"); - $sb->add_bool_option("downtime", "Disable non-admin access: "); - $sb->add_longtext_option("downtime_message", "
"); - $event->panel->add_block($sb); - } + public function onPageRequest($event) { + global $config, $page, $user; - if($event instanceof PageRequestEvent) { - if($config->get_bool("downtime")) { - if(!$user->is_admin() && !$this->is_safe_page($event)) { - $msg = $config->get_string("downtime_message"); - $this->theme->display_message($msg); - exit; - } - $this->theme->display_notification($page); + if($config->get_bool("downtime")) { + if(!$user->is_admin() && !$this->is_safe_page($event)) { + $msg = $config->get_string("downtime_message"); + $this->theme->display_message($msg); + exit; } + $this->theme->display_notification($page); } }