Commit 660f3062 authored by lphuberdeau's avatar lphuberdeau

[NEW] Allow hosts to specify a system configuration file to override preferences

parent 9d5e37ed
......@@ -98,7 +98,26 @@ $tikidomainslash = (!empty($tikidomain) ? $tikidomain . '/' : '');
$re = false;
$default_api_tiki = $api_tiki;
$api_tiki = '';
if ( file_exists($local_php) ) $re = include($local_php);
if ( file_exists($local_php) ) {
$re = include($local_php);
}
global $systemConfiguration;
$systemConfiguration = new Zend_Config(array(
'preference' => array(),
), array(
'readOnly' => false,
));
if (isset ($system_configuration_file)) {
if (! is_readable($system_configuration_file)) {
die('Configuration file could not be read.');
}
if (! isset($system_configuration_identifier)) {
$system_configuration_identifier = null;
}
$systemConfiguration = $systemConfiguration->merge(new Zend_Config_Ini($system_configuration_file, $system_configuration_identifier));
}
if ( empty( $api_tiki ) ) {
$api_tiki_forced = false;
$api_tiki = $default_api_tiki;
......@@ -118,7 +137,6 @@ if ( $re === false ) {
if ( $dbversion_tiki == '1.10' ) $dbversion_tiki = '2.0';
require_once 'lib/core/TikiDb/ErrorHandler.php';
class TikiDb_LegacyErrorHandler implements TikiDb_ErrorHandler
{
function handle( TikiDb $db, $query, $values, $result ) // {{{
......
......@@ -113,7 +113,10 @@ function write_local_php($dbb_tiki, $host_tiki, $user_tiki, $pass_tiki, $dbs_tik
$filetowrite .= "// \$client_charset='utf8';\n";
$filetowrite .= "// See http://tiki.org/ReleaseNotes5.0#Known_Issues and http://doc.tiki.org/Understanding+Encoding for more info\n\n";
$filetowrite .= "// If your php installation does not not have pdo extension\n";
$filetowrite .= "// \$api_tiki = 'adodb';\n";
$filetowrite .= "// \$api_tiki = 'adodb';\n\n";
$filetowrite .= "// Want configurations managed at the system level or restrict some preferences? http://doc.tiki.org/System+Configuration\n";
$filetowrite .= "// \$system_configuration_file = '/etc/tiki.ini';\n";
$filetowrite .= "// \$system_configuration_identifier = 'example.com';\n\n";
fwrite($fw, $filetowrite);
fclose($fw);
}
......
......@@ -18,7 +18,7 @@ class PreferencesLib
}
function getPreference( $name, $deps = true, $source = null, $get_pages = false ) {
global $prefs;
global $prefs, $systemConfiguration;
static $id = 0;
$data = $this->loadData( $name );
......@@ -58,6 +58,8 @@ class PreferencesLib
$info['value'] = $value;
}
$info['notes'] = array();
$info['raw'] = $source[$name];
$info['id'] = 'pref-' . ++$id;
......@@ -83,7 +85,10 @@ class PreferencesLib
$info['available'] = true;
if( isset( $info['extensions'] ) ) {
$info['available'] = $this->checkExtensions( $info['extensions'] );
if (! $this->checkExtensions( $info['extensions'] ) ) {
$info['available'] = false;
$info['notes'][] = tr('Unmatched system requirement. Missing php extension among %0', implode(', ', $info['extensions']));
}
}
$defprefs = get_default_prefs();
$info['default_val'] = $defprefs[$name];
......@@ -91,6 +96,11 @@ class PreferencesLib
if ($get_pages) {
$info['pages'] = $this->getPreferenceLocations( $name );
}
if( isset( $systemConfiguration->preference->$name ) ) {
$info['available'] = false;
$info['notes'][] = tr('Configuration forced by host.');
}
$info = array_merge($defaults, $info);
......
......@@ -411,7 +411,8 @@ function initialize_prefs() {
}
$prefs = empty($modified) ? $defaults : array_merge( $defaults, $modified );
global $systemConfiguration;
$prefs = array_merge($prefs, $systemConfiguration->preference->toArray());
}
// PHP fonctionnalities
......
......@@ -2048,7 +2048,7 @@ ul.freetagged li {
/* Preferences */
.pref_dependency {
margin-left: 20px;
margin-left: 33px;
font-size: 95%;
}
......@@ -2056,6 +2056,12 @@ img.pref_dependency {
opacity: 0.25;
}
.pref_note {
margin-left: 33px;
font-size: 90%;
font-style: italic;
}
/* Perspectives (edit) */
.podcast {
......
......@@ -8,3 +8,6 @@
{/if}
{/foreach}
{/if}
{foreach from=$p.notes item=note}
<div class="pref_note">{$note|escape}</div>
{/foreach}
......@@ -13,7 +13,7 @@
</a>
{/if}
{if $p.value|stringfix:"\r\n":"\n" neq $p.default_val}
{if $p.value|stringfix:"\r\n":"\n" neq $p.default_val and $p.available}
<input class="pref-reset system" type="checkbox" name="lm_reset[]" value="{$p.preference|escape}" style="display:none" />
<input type="hidden" id="{$p.preference|escape}_default" value="{$p.default_val|escape}" />
{/if}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment