summaryrefslogtreecommitdiff
path: root/program/include/rcube_config.php
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2009-05-21 20:34:28 +0000
committerthomascube <thomas@roundcube.net>2009-05-21 20:34:28 +0000
commitc73b195e5d02a09d56430dd6e666313b86fee2f9 (patch)
treedec1d935a0a9dda33b2a4771a3a03c325d02d64a /program/include/rcube_config.php
parent66f68e96236848e8f1dd5992f1d7d0c5cc6da2a9 (diff)
Add function for plugins to load a local config file
Diffstat (limited to 'program/include/rcube_config.php')
-rw-r--r--program/include/rcube_config.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index 56f577bda..d4adb7bd1 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -51,15 +51,11 @@ class rcube_config
ob_start();
// load main config file
- if (include(RCMAIL_CONFIG_DIR . '/main.inc.php'))
- $this->prop = (array)$rcmail_config;
- else
+ if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php'))
$this->errors[] = 'main.inc.php was not found.';
// load database config
- if (include(RCMAIL_CONFIG_DIR . '/db.inc.php'))
- $this->prop += (array)$rcmail_config;
- else
+ if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php'))
$this->errors[] = 'db.inc.php was not found.';
// load host-specific configuration
@@ -124,10 +120,30 @@ class rcube_config
$fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php';
}
- if ($fname && is_file(RCMAIL_CONFIG_DIR . '/' . $fname)) {
- include(RCMAIL_CONFIG_DIR . '/' . $fname);
- $this->prop = array_merge($this->prop, (array)$rcmail_config);
+ if ($fname) {
+ $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname);
+ }
+ }
+
+
+ /**
+ * Read configuration from a file
+ * and merge with the already stored config values
+ *
+ * @param string Full path to the config file to be loaded
+ * @return booelan True on success, false on failure
+ */
+ public function load_from_file($fpath)
+ {
+ if (is_file($fpath)) {
+ @include($fpath);
+ if (is_array($rcmail_config)) {
+ $this->prop = array_merge($this->prop, $rcmail_config);
+ return true;
+ }
}
+
+ return false;
}