From b29ca9b5d49eab543ceac4c76e16fbd096432a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Sat, 15 Jun 2013 14:35:02 +0200 Subject: [PATCH] MDL-26455 add custom DB port and socket to web installer --- install.php | 23 ++++++++++++++++------- lang/en/install.php | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/install.php b/install.php index 7acf6d5d9e77e..d71e7a584632f 100644 --- a/install.php +++ b/install.php @@ -129,7 +129,12 @@ $config->dbpass = trim($_POST['dbpass']); $config->dbname = trim($_POST['dbname']); $config->prefix = trim($_POST['prefix']); - $config->dbsocket = (int)(!empty($_POST['dbsocket'])); + $config->dbport = (int)trim($_POST['dbport']); + $config->dbsocket = trim($_POST['dbsocket']); + + if ($config->dbport <= 0) { + $config->dbport = ''; + } $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']); @@ -144,7 +149,8 @@ $config->dbpass = ''; $config->dbname = 'moodle'; $config->prefix = 'mdl_'; - $config->dbsocket = 0; + $config->dbport = empty($distro->dbport) ? '' : $distro->dbport; + $config->dbsocket = empty($distro->dbsocket) ? '' : $distro->dbsocket; $config->admin = 'admin'; @@ -263,9 +269,9 @@ $config->stage = INSTALL_DATABASETYPE; } else { if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation - $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket), $distro); + $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket), $distro); } - $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket)); + $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket)); if ($hint_database === '') { $configphp = install_generate_configphp($database, $CFG); @@ -405,6 +411,7 @@ $strdbuser = get_string('databaseuser', 'install'); $strdbpass = get_string('databasepass', 'install'); $strprefix = get_string('dbprefix', 'install'); + $strdbport = get_string('databaseport', 'install'); $strdbsocket = get_string('databasesocket', 'install'); echo '
'; @@ -432,11 +439,13 @@ echo ''; echo '
'; + echo '
'; + echo ''; + echo '
'; + if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) { - $checked = $config->dbsocket ? 'checked="checked' : ''; echo '
'; - echo ''; - echo ''; + echo ''; echo '
'; } diff --git a/lang/en/install.php b/lang/en/install.php index e936e0d06e2ad..f744ec593c6b4 100644 --- a/lang/en/install.php +++ b/lang/en/install.php @@ -86,6 +86,7 @@ $string['databasehost'] = 'Database host'; $string['databasename'] = 'Database name'; $string['databasepass'] = 'Database password'; +$string['databaseport'] = 'Database port'; $string['databasesettings'] = 'Now you need to configure the database where most Moodle data will be stored. This database must already have been created and a username and password created to access it.