From 0eb11397722ff6dcf9edfa22933993160f12ca1c Mon Sep 17 00:00:00 2001 From: marcus Date: Mon, 16 Jun 2008 18:00:07 +0000 Subject: CLOSED - #30: $CONFIG is not populated from elggconfig or datalists http://trac.elgg.org/elgg/ticket/30 git-svn-id: https://code.elgg.org/elgg/trunk@937 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/configuration.php | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php index 04257de42..48eeeebfc 100644 --- a/engine/lib/configuration.php +++ b/engine/lib/configuration.php @@ -30,7 +30,7 @@ if ($site_guid == 0) $site_guid = (int) $CONFIG->site_id; $CONFIG->$name = $value; - $value = serialize($value); + $value = sanitise_string(serialize($value)); return insert_data("insert into {$CONFIG->dbprefix}config set name = '{$name}', value = '{$value}', site_guid = {$site_guid}"); } @@ -59,6 +59,33 @@ } return false; + } + + /** + * Gets all the configuration details in the config database for a given site. + * + * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default) + */ + function get_all_config($site_guid = 0) + { + global $CONFIG; + + $site_guid = (int) $site_guid; + + if ($site_guid == 0) + $site_guid = (int) $CONFIG->site_id; + + if ($result = get_data("select * from {$CONFIG->dbprefix}config where site_guid = {$site_guid}")) { + foreach ($result as $r) + { + $name = $r->name; + $value = $r->value; + $CONFIG->$name = unserialize($value); + } + + return true; + } + return false; } /** @@ -101,9 +128,7 @@ if (empty($CONFIG->sitename)) $CONFIG->sitename = "New Elgg site"; - - if (empty($CONFIG->debug)) - $CONFIG->debug = false; + } @@ -129,6 +154,9 @@ $CONFIG->sitename = $CONFIG->site->name; } $CONFIG->url = $CONFIG->wwwroot; + + // Load default settings from database + get_all_config(); return true; -- cgit v1.2.3