downtime -> simpleext

This commit is contained in:
Shish 2012-01-30 02:24:17 +00:00
parent 7af442855d
commit 39e8e8b733

View File

@ -11,23 +11,19 @@
* message specified in the box. * message specified in the box.
*/ */
class Downtime implements Extension { class Downtime extends SimpleExtension {
var $theme;
public function get_priority() {return 10;} public function get_priority() {return 10;}
public function receive_event(Event $event) { public function onSetupBuilding($event) {
global $config, $database, $page, $user;
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Downtime"); $sb = new SetupBlock("Downtime");
$sb->add_bool_option("downtime", "Disable non-admin access: "); $sb->add_bool_option("downtime", "Disable non-admin access: ");
$sb->add_longtext_option("downtime_message", "<br>"); $sb->add_longtext_option("downtime_message", "<br>");
$event->panel->add_block($sb); $event->panel->add_block($sb);
} }
if($event instanceof PageRequestEvent) { public function onPageRequest($event) {
global $config, $page, $user;
if($config->get_bool("downtime")) { if($config->get_bool("downtime")) {
if(!$user->is_admin() && !$this->is_safe_page($event)) { if(!$user->is_admin() && !$this->is_safe_page($event)) {
$msg = $config->get_string("downtime_message"); $msg = $config->get_string("downtime_message");
@ -37,7 +33,6 @@ class Downtime implements Extension {
$this->theme->display_notification($page); $this->theme->display_notification($page);
} }
} }
}
private function is_safe_page(PageRequestEvent $event) { private function is_safe_page(PageRequestEvent $event) {
if($event->page_matches("user_admin/login")) return true; if($event->page_matches("user_admin/login")) return true;