aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-29 12:36:38 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-29 12:36:38 +0000
commitf0e7d14c218696142b41e0183dc734ddff162018 (patch)
tree9d085eaef6bf5425796951cc50c3c50bbb666417
parente7fd07af05e1812e08a2e5ea39912e61af17d2d1 (diff)
downloadelgg-f0e7d14c218696142b41e0183dc734ddff162018.tar.gz
elgg-f0e7d14c218696142b41e0183dc734ddff162018.tar.bz2
Refs #2428 added elgg_get_config(), elgg_set_config(), and elgg_save_config()
git-svn-id: http://code.elgg.org/elgg/trunk@7470 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/configuration.php86
-rw-r--r--views/default/page_shells/admin.php10
-rw-r--r--views/default/page_shells/default.php10
-rw-r--r--views/default/page_shells/walled_garden.php7
4 files changed, 100 insertions, 13 deletions
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
index b222b6b4f..bf5122653 100644
--- a/engine/lib/configuration.php
+++ b/engine/lib/configuration.php
@@ -18,6 +18,92 @@
*/
/**
+ * Get an Elgg configuration value
+ *
+ * @param string $name Name of the configuration value
+ * @param int $site_guid NULL for installation setting, 0 for default site
+ *
+ * @return mixed Configuration value or false if it does not exist
+ * @since 1.8.0
+ */
+function elgg_get_config($name, $site_guid = 0) {
+ global $CONFIG;
+
+ $name = trim($name);
+
+ if (isset($CONFIG->$name)) {
+ return $CONFIG->$name;
+ }
+
+ if ($site_guid === NULL) {
+ // installation wide setting
+ $value = datalist_get($name);
+ } else {
+ // site specific setting
+ if ($site_guid == 0) {
+ $site_guid = (int) $CONFIG->site_id;
+ }
+ $value = get_config($name, $site_guid);
+ }
+
+ if ($value !== false) {
+ $CONFIG->$name = $value;
+ return $value;
+ }
+
+ return false;
+}
+
+/**
+ * Set an Elgg configuration value
+ *
+ * @warning This does not persist the configuration setting. Use elgg_save_config()
+ *
+ * @param string $name Name of the configuration value
+ * @param mixed $value Value
+ *
+ * @return void
+ * @since 1.8.0
+ */
+function elgg_set_config($name, $value) {
+ global $CONFIG;
+
+ $name = trim($name);
+
+ $CONFIG->$name = $value;
+}
+
+/**
+ * Save a configuration setting
+ *
+ * @param string $name Configuration name
+ * @param mixed $value Configuration value. Should be string for installation setting
+ * @param int $site_guid NULL for installation setting, 0 for default site
+ *
+ * @return bool
+ * @since 1.8.0
+ */
+function elgg_save_config($name, $value, $site_guid = 0) {
+ global $CONFIG;
+
+ $name = trim($name);
+
+ elgg_set_config($name, $value);
+
+ if ($site_guid === NULL) {
+ if (is_array($value) || is_object($value)) {
+ return false;
+ }
+ return datalist_set($name, $value);
+ } else {
+ if ($site_guid == 0) {
+ $site_guid = (int) $CONFIG->site_id;
+ }
+ return set_config($name, $value, $site_guid);
+ }
+}
+
+/**
* Check that installation has completed and the database is populated.
*
* @throws InstallationException
diff --git a/views/default/page_shells/admin.php b/views/default/page_shells/admin.php
index cc65b6fda..9fdbf2e28 100644
--- a/views/default/page_shells/admin.php
+++ b/views/default/page_shells/admin.php
@@ -5,22 +5,22 @@
* @package Elgg
* @subpackage Core
*
- * @uses $vars['config'] The site configuration settings, imported
* @uses $vars['title'] The page title
* @uses $vars['body'] The main content of the page
- * @uses $vars['messages'] A 2d array of various message registers, passed from system_messages()
+ * @uses $vars['sysmessages'] A 2d array of various message registers, passed from system_messages()
*/
// Set the content type
header("Content-type: text/html; charset=UTF-8");
// Set title
+$site_title = elgg_get_config('sitename');
if (empty($vars['title'])) {
- $title = $vars['config']->sitename;
-} else if (empty($vars['config']->sitename)) {
+ $title = $site_title;
+} else if (empty($site_title)) {
$title = $vars['title'];
} else {
- $title = $vars['config']->sitename . ": " . $vars['title'];
+ $title = $site_title . ": " . $vars['title'];
}
echo elgg_view('page_elements/html_begin', $vars);
diff --git a/views/default/page_shells/default.php b/views/default/page_shells/default.php
index 30196a139..0fd407a3d 100644
--- a/views/default/page_shells/default.php
+++ b/views/default/page_shells/default.php
@@ -6,22 +6,22 @@
* @package Elgg
* @subpackage Core
*
- * @uses $vars['config'] The site configuration settings, imported
* @uses $vars['title'] The page title
* @uses $vars['body'] The main content of the page
- * @uses $vars['messages'] A 2d array of various message registers, passed from system_messages()
+ * @uses $vars['sysmessages'] A 2d array of various message registers, passed from system_messages()
*/
// Set the content type
header("Content-type: text/html; charset=UTF-8");
// Set title
+$site_title = elgg_get_config('sitename');
if (empty($vars['title'])) {
- $title = $vars['config']->sitename;
-} else if (empty($vars['config']->sitename)) {
+ $title = $site_title;
+} else if (empty($site_title)) {
$title = $vars['title'];
} else {
- $title = $vars['config']->sitename . ": " . $vars['title'];
+ $title = $site_title . ": " . $vars['title'];
}
echo elgg_view('page_elements/html_begin', $vars);
diff --git a/views/default/page_shells/walled_garden.php b/views/default/page_shells/walled_garden.php
index 0da1aeb67..cdd3982ec 100644
--- a/views/default/page_shells/walled_garden.php
+++ b/views/default/page_shells/walled_garden.php
@@ -7,12 +7,13 @@
header("Content-type: text/html; charset=UTF-8");
// Set title
+$site_title = elgg_get_config('sitename');
if (empty($vars['title'])) {
- $title = $vars['config']->sitename;
-} elseif (empty($vars['config']->sitename)) {
+ $title = $site_title;
+} else if (empty($site_title)) {
$title = $vars['title'];
} else {
- $title = $vars['config']->sitename . ": " . $vars['title'];
+ $title = $site_title . ": " . $vars['title'];
}
echo elgg_view('page_elements/html_begin', $vars);