From 1ba0fab3389b57e0167c9df94ed19602cc4103af Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 1 May 2008 16:30:51 +0000 Subject: Major site config changes git-svn-id: https://code.elgg.org/elgg/trunk@615 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 2 +- engine/lib/install.php | 32 ++++++++++++++++++++++++++++++++ engine/lib/sites.php | 22 ++++++++++------------ engine/schema/mysql.sql | 2 +- 4 files changed, 44 insertions(+), 14 deletions(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 37245a6db..9005cf010 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -870,7 +870,7 @@ * @return true|false Depending on success. */ function run_function_once($functionname, $timelastupdatedcheck = 0) { - if ($lastupdated = datalist_get($name)) { + if ($lastupdated = datalist_get($functionname)) { $lastupdated = (int) $lastupdated; } else { $lastupdated = 0; diff --git a/engine/lib/install.php b/engine/lib/install.php index 79b170842..a5e1b6f4d 100644 --- a/engine/lib/install.php +++ b/engine/lib/install.php @@ -42,4 +42,36 @@ } + /** + * Function that gets run once, when the system is first installed + * + */ + function install_prerequisites() { + + // Load existing config + global $CONFIG; + + // Create a new Elgg site + $site = new ElggSite(); + $site->save(); + + // Set datalist alerting us to the fact that the default site is this one + datalist_set('default_site',$site->getGUID()); + + } + + /** + * Functions to be run at install init-time. + * + */ + function install_init() { + + // Run the install_prerequisites function just once + run_function_once("install_prerequisites"); + + } + + // Make sure install_boot gets called on system book + register_event_handler('init','system','install_init',1); + ?> \ No newline at end of file diff --git a/engine/lib/sites.php b/engine/lib/sites.php index a0d5005ee..89ab9bd80 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -462,24 +462,22 @@ * @return true */ function sites_init($event, $object_type, $object) { - /* global $CONFIG; - $CONFIG->site_id = 1; - - trigger_event('init','sites'); - - if ($site = get_data_row("select * from {$CONFIG->dbprefix}sites where id = 1")) { - if (!empty($site->name)) - $CONFIG->sitename = $site->name; - if (!empty($site->domain)) - $CONFIG->wwwroot = $site->domain; + global $CONFIG; + $site = trigger_plugin_hook("siteid","system"); + if ($site === null || $site === false) { + $CONFIG->site_id = (int) datalist_get('default_site'); + } else { + $CONFIG->site_id = $site; } + $CONFIG->site_guid = $CONFIG->site_id; + + return true; - return true;*/ } // Register event handlers - register_event_handler('init','system','sites_init',0); + register_event_handler('init','system','sites_init',2); ?> \ No newline at end of file diff --git a/engine/schema/mysql.sql b/engine/schema/mysql.sql index 5c71a3192..078a64520 100644 --- a/engine/schema/mysql.sql +++ b/engine/schema/mysql.sql @@ -229,7 +229,7 @@ CREATE TABLE `prefix_users_apisessions` ( -- Datalists for things like db version CREATE TABLE `prefix_datalists` ( - `name` varchar(16) NOT NULL, + `name` varchar(32) NOT NULL, `value` text NOT NULL, KEY `name` (`name`) ); -- cgit v1.2.3