Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.54 diff -u -r1.54 bootstrap.inc --- includes/bootstrap.inc 27 Jun 2005 18:38:46 -0000 1.54 +++ includes/bootstrap.inc 29 Jun 2005 11:21:46 -0000 @@ -203,6 +203,13 @@ /** * Return a persistent variable. * + * If defined, the variable_override and variable_default functions + * will be checked before returning a value. An overridden variable + * will always be returned, whereas a custom default value will + * be returned only if no value was found in the database. This is + * particularly useful for multi-site hosts who do not want users + * changing the file_path or other sensitive variables. + * * @param $name * The name of the variable to return. * @param $default @@ -213,6 +220,15 @@ function variable_get($name, $default) { global $conf; + if (function_exists('variable_override')) { + $value = variable_override($name); + if (isset($value)) { + return $value; + } + } + elseif (function_exists('variable_default')) { + $default = (variable_default($name)) ? variable_default($name) : $default; + } return isset($conf[$name]) ? $conf[$name] : $default; } @@ -228,6 +244,18 @@ function variable_set($name, $value) { global $conf; + /** + * Retrieve the overridden value, if it exists. + */ + if (function_exists('variable_override')) { + if ($override = variable_override($name)) { + if ($value != $override) { + form_set_error($name, t('The variable %NAME has been locked by your administrator and cannot be modified.', array('%NAME' => $name))); + $value = $override; + } + } + } + db_query('LOCK TABLES {variable} WRITE'); db_query("DELETE FROM {variable} WHERE name = '%s'", $name); db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value)); @@ -823,6 +851,9 @@ global $db_url, $base_url; unset($conf); require_once conf_init() .'/settings.php'; + if (file_exists('sites/global.php')) { + require_once 'sites/global.php'; + } require_once './includes/database.inc'; // Initialize the default database. db_set_active();