From 09fba458f79b8b1b1940405911915feade1989bf Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 18 Jun 2008 11:10:16 +0000 Subject: Fixes #17 - Debug mode toggle. Introduced unset_config() which is also called automatically by set_config(). Also modified the view input/checkboxes to set values on the checkbox. git-svn-id: https://code.elgg.org/elgg/trunk@961 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/configuration.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'engine/lib/configuration.php') diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php index acb651170..a033d679f 100644 --- a/engine/lib/configuration.php +++ b/engine/lib/configuration.php @@ -12,7 +12,26 @@ * @link http://elgg.org/ */ - + + /** + * Unset a config option. + * + * @param string $name The name of the field. + * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default). + * @return mixed + */ + function unset_config($name, $site_guid = 0) + { + global $CONFIG; + + $name = mysql_real_escape_string($name); + $site_guid = (int) $site_guid; + if ($site_guid == 0) + $site_guid = (int) $CONFIG->site_id; + + return delete_data("delete from {$CONFIG->dbprefix}config where name='$name' and site_guid=$site_guid"); + } + /** * Sets a configuration value * @@ -23,14 +42,19 @@ */ function set_config($name, $value, $site_guid = 0) { - global $CONFIG; + global $CONFIG; + + // Unset existing + unset_config($name,$site_guid); + $name = mysql_real_escape_string($name); $value = mysql_real_escape_string($value); $site_guid = (int) $site_guid; if ($site_guid == 0) $site_guid = (int) $CONFIG->site_id; $CONFIG->$name = $value; - $value = sanitise_string(serialize($value)); + $value = sanitise_string(serialize($value)); + return insert_data("insert into {$CONFIG->dbprefix}config set name = '{$name}', value = '{$value}', site_guid = {$site_guid}"); } -- cgit v1.2.3