aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-01 14:55:30 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-01 14:55:30 +0000
commit0f2141e90dd03bb66318ec8776fada3ef8569ef9 (patch)
treed346997d600a28f87595a68251d275a85df6975a /engine/lib
parent482bc3b465e311db57d4ead4a23f826eedfb4372 (diff)
downloadelgg-0f2141e90dd03bb66318ec8776fada3ef8569ef9.tar.gz
elgg-0f2141e90dd03bb66318ec8776fada3ef8569ef9.tar.bz2
Get and set per-site configuration values from the database
git-svn-id: https://code.elgg.org/elgg/trunk@600 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/configuration.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
index 6b2bfbb49..efffb5e8d 100644
--- a/engine/lib/configuration.php
+++ b/engine/lib/configuration.php
@@ -12,6 +12,55 @@
* @link http://elgg.org/
*/
+
+ /**
+ * Enter description here...
+ *
+ * @param unknown_type $name
+ * @param unknown_type $value
+ * @param unknown_type $site_guid
+ * @return unknown
+ */
+ function set_config($name, $value, $site_guid = 0) {
+
+ global $CONFIG;
+ $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 = serialize($value);
+ return insert_data("insert into {$CONFIG->dbprefix}config set name = '{$name}', value = '{$value}', site_guid = {$site_guid}");
+
+ }
+
+ /**
+ * Gets a configuration value
+ *
+ * @param string $name The name of the config value
+ * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default)
+ * @return mixed|false Depending on success
+ */
+ function get_config($name, $site_guid = 0) {
+
+ global $CONFIG;
+ if (isset($CONFIG->$name))
+ return $CONFIG->$name;
+ $name = mysql_real_escape_string($name);
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0)
+ $site_guid = (int) $CONFIG->site_id;
+ if ($result = get_data_row("select value from {$CONFIG->dbprefix}config where name = '{$name}' and site_guid = {$site_guid}")) {
+ $result = $result->value;
+ $result = unserialize($result->value);
+ $CONFIG->$name = $result;
+ return $result;
+ }
+ return false;
+
+ }
+
/**
* If certain configuration elements don't exist, autodetect sensible defaults
*