downtime -> simpleext
This commit is contained in:
parent
7af442855d
commit
39e8e8b733
@ -11,23 +11,19 @@
|
||||
* 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);
|
||||
|
||||
if($event instanceof SetupBuildingEvent) {
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Downtime");
|
||||
$sb->add_bool_option("downtime", "Disable non-admin access: ");
|
||||
$sb->add_longtext_option("downtime_message", "<br>");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
if($event instanceof PageRequestEvent) {
|
||||
public function onPageRequest($event) {
|
||||
global $config, $page, $user;
|
||||
|
||||
if($config->get_bool("downtime")) {
|
||||
if(!$user->is_admin() && !$this->is_safe_page($event)) {
|
||||
$msg = $config->get_string("downtime_message");
|
||||
@ -37,7 +33,6 @@ class Downtime implements Extension {
|
||||
$this->theme->display_notification($page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function is_safe_page(PageRequestEvent $event) {
|
||||
if($event->page_matches("user_admin/login")) return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user