From 86453d8bd6e4fa7762677bcaf27ca733bfa7eb36 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 13 Oct 2006 18:20:52 +0000 Subject: [PATCH] Now installer:(MDL-6823) - performs Oracle charset checks (both client and server) - prefix checks - shows differnt information foreach DB flavour - provide one link to Moodle Docs for MSSQL and Oracle - the ODBC connector has been marked as experimental due to confirmed problems by MS Merged from MOODLE_17_STABLE --- install.php | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 158 insertions(+), 4 deletions(-) diff --git a/install.php b/install.php index 64f74d0254..66005c9480 100644 --- a/install.php +++ b/install.php @@ -140,7 +140,9 @@ $INSTALL['version'] = $version; $INSTALL['release'] = $release; /// Have the $db object ready because we are going to use it often +define ('ADODB_ASSOC_CASE', 0); //Use lowercase fieldnames for ADODB_FETCH_ASSOC $db = &ADONewConnection($INSTALL['dbtype']); +$db->SetFetchMode(ADODB_FETCH_ASSOC); /// guess the www root if ($INSTALL['wwwroot'] == '') { @@ -280,6 +282,50 @@ if ($INSTALL['stage'] == DATABASE) { } } + if ($INSTALL['dbtype'] == 'postgres7') { /// Check PostgreSQL extension is present + if (!extension_loaded('pgsql')) { + $errormsg = get_string('pgsqlextensionisnotpresentinphp', 'install'); + $nextstage = DATABASE; + } + } + + if ($INSTALL['dbtype'] == 'mssql') { /// Check MSSQL extension is present + if (!extension_loaded('mssql')) { + $errormsg = get_string('mssqlextensionisnotpresentinphp', 'install'); + $nextstage = DATABASE; + } + } + + if ($INSTALL['dbtype'] == 'odbc_mssql') { /// Check ODBC extension is present + if (!extension_loaded('odbc')) { + $errormsg = get_string('odbcextensionisnotpresentinphp', 'install'); + $nextstage = DATABASE; + } + } + + if ($INSTALL['dbtype'] == 'oci8po') { /// Check OCI extension is present + if (!extension_loaded('oci8')) { + $errormsg = get_string('ociextensionisnotpresentinphp', 'install'); + $nextstage = DATABASE; + } + } + + if (empty($INSTALL['prefix']) && $INSTALL['dbtype'] != 'mysql') { // All DBs but MySQL require prefix (reserv. words) + $errormsg = get_string('dbwrongprefix', 'install'); + $nextstage = DATABASE; + } + + if ($INSTALL['dbtype'] == 'oci8po' && strlen($INSTALL['prefix']) > 2) { // Oracle max prefix = 2cc (30cc limit) + $errormsg = get_string('dbwrongprefix', 'install'); + $nextstage = DATABASE; + } + + if ($INSTALL['dbtype'] == 'oci8po' && !empty($INSTALL['dbhost'])) { // Oracle host must be blank (tnsnames.ora has it) + $errormsg = get_string('dbwronghostserver', 'install'); + $nextstage = DATABASE; + } + + if (empty($errormsg)) { error_reporting(0); // Hide errors @@ -354,6 +400,26 @@ if ($INSTALL['stage'] == DATABASE) { } } break; + case 'oci8po': + ///Get Oracle NLS_CHARACTERSET value + $rs = $db->Execute("SELECT value FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET'"); + if ($rs && $rs->RecordCount() > 0) { + $encoding = $rs->fields['value']; + if (strtoupper($encoding) != 'AL32UTF8') { + $errormsg = get_string('dbwrongencoding', 'install', $encoding); + $nextstage = DATABASE; + $INSTALL['dbencodingtestresults'] = false; + } else { + $INSTALL['dbencodingtestresults'] = true; + } + } + /// Get client NLS_LANG environment variable + if (strpos(getenv('NLS_LANG'), 'AL32UTF8') === false) { // Oracle client must be correct UTF8 + $errormsg = get_string('dbwrongnlslang', 'install', $encoding); + $nextstage = DATABASE; + $INSTALL['dbencodingtestresults'] = false; + } + break; } } } @@ -534,6 +600,7 @@ if ($nextstage == SAVE) { Moodle Install + @@ -561,9 +628,40 @@ if (isset($_GET['help'])) {

- -

- + window.onload=toggledbinfo;'; + echo '
' . get_string('databasesettingssub_mysql', 'install') . '
'; + + echo '
' . get_string('databasesettingssub_postgres7', 'install') . '
'; + + echo '
' . get_string('databasesettingssub_mssql', 'install'); + /// Link to mssql installation page + echo '

'; + echo 'Docs'; + echo get_string('moodledocslink', 'install') . '

'; + echo '
'; + + echo '
'. get_string('databasesettingssub_odbc_mssql', 'install'); + /// Link to mssql installation page + echo '

'; + echo 'Docs'; + echo get_string('moodledocslink', 'install') . '

'; + echo '
'; + + echo '
' . get_string('databasesettingssub_oci8po', 'install'); + /// Link to mssql installation page + echo '

'; + echo 'Docs'; + echo get_string('moodledocslink', 'install') . '

'; + echo '
'; + } else { + if (!empty($substagetext[$nextstage])) { + echo '

' . $substagetext[$nextstage] . '

'; + } + } + ?> @@ -740,7 +838,12 @@ function form_table($nextstage = WELCOME, $formaction = "install.php") {

- "mysql", "postgres7" => "postgres7", 'mssql' => 'mssql'), 'dbtype', $INSTALL['dbtype'], '') ?> + get_string('mysql', 'install'), + 'oci8po' => get_string('oci8po', 'install'), + 'postgres7' => get_string('postgres7', 'install'), + 'mssql' => get_string('mssql', 'install'), + 'odbc_mssql' => get_string('odbc_mssql', 'install')), + 'dbtype', $INSTALL['dbtype'], '', 'toggledbinfo();') ?> @@ -1130,9 +1233,60 @@ function css_styles() { padding: 20px; color: #ff0000; } + #mysql, #postgres7, #mssql, #odbc_mssql, #oci8po { + display: none; + } + + + + -- 2.39.5