From 7762b2c7037ae8579ebbc60e6d8452009270f43b Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 3 Aug 2015 15:40:20 +0100 Subject: [PATCH] do InitExtEvent in bootstrap, before user exists --- core/_bootstrap.inc.php | 1 + core/event.class.php | 2 ++ ext/blotter/main.php | 1 - ext/custom_html_headers/main.php | 30 +++++++++++++++--------------- index.php | 1 - 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/_bootstrap.inc.php b/core/_bootstrap.inc.php index b1e6f72c..77fcbc1d 100644 --- a/core/_bootstrap.inc.php +++ b/core/_bootstrap.inc.php @@ -46,3 +46,4 @@ ctx_log_endok(); // hook up event handlers _load_event_listeners(); +send_event(new InitExtEvent()); diff --git a/core/event.class.php b/core/event.class.php index c06ff99d..f1db791d 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -13,6 +13,8 @@ abstract class Event { * A wake-up call for extensions. Upon recieving an InitExtEvent an extension * should check that it's database tables are there and install them if not, * and set any defaults with Config::set_default_int() and such. + * + * This event is sent before $user is set to anything */ class InitExtEvent extends Event {} diff --git a/ext/blotter/main.php b/ext/blotter/main.php index 191d20ff..8460932c 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -41,7 +41,6 @@ class Blotter extends Extension { $config->set_default_int("blotter_recent", 5); $config->set_default_string("blotter_color", "FF0000"); $config->set_default_string("blotter_position", "subheading"); - } public function onSetupBuilding(SetupBuildingEvent $event) { diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php index d8dc8b57..f3ed3b6b 100644 --- a/ext/custom_html_headers/main.php +++ b/ext/custom_html_headers/main.php @@ -15,23 +15,23 @@ * You can also add your website name as prefix or suffix to the title of each page on your website. */ class custom_html_headers extends Extension { - # Adds setup block for custom content - public function onSetupBuilding(SetupBuildingEvent $event) { - global $config; - +# Adds setup block for custom content + public function onSetupBuilding(SetupBuildingEvent $event) { + global $config; + $sb = new SetupBlock("Custom HTML Headers"); - - // custom headers + + // custom headers $sb->add_longtext_option("custom_html_headers", - "HTML Code to place within <head></head> on all pages
"); - - // modified title - $sb->add_choice_option("sitename_in_title", array( - "none" => 0, - "as prefix" => 1, - "as suffix" => 2 - ), "
Add website name in title"); - + "HTML Code to place within <head></head> on all pages
"); + + // modified title + $sb->add_choice_option("sitename_in_title", array( + "none" => 0, + "as prefix" => 1, + "as suffix" => 2 + ), "
Add website name in title"); + $event->panel->add_block($sb); } diff --git a/index.php b/index.php index a629da01..76f4f8bb 100644 --- a/index.php +++ b/index.php @@ -54,7 +54,6 @@ try { // start the page generation waterfall $user = _get_user(); - send_event(new InitExtEvent()); if(PHP_SAPI === 'cli') { send_event(new CommandEvent($argv)); }