Skip to content

Commit

Permalink
MDL-26455 add custom DB port and socket to web installer
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jun 15, 2013
1 parent f192883 commit b29ca9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 16 additions & 7 deletions install.php
Expand Up @@ -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']);

Expand All @@ -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';

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 '<div class="userinput">';
Expand Down Expand Up @@ -432,11 +439,13 @@
echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
echo '</div>';

echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strdbport.'</label>';
echo '<input id="id_dbport" name="dbport" type="text" value="'.s($config->dbport).'" size="10" class="forminput" />';
echo '</div>';

if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
$checked = $config->dbsocket ? 'checked="checked' : '';
echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
echo '<input type="hidden" value="0" name="dbsocket" />';
echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
echo '<input id="id_dbsocket" name="dbsocket" type="text" value="'.s($config->dbsocket).'" size="50" class="forminput" />';
echo '</div>';
}

Expand Down
1 change: 1 addition & 0 deletions lang/en/install.php
Expand Up @@ -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.<br />
Expand Down

0 comments on commit b29ca9b

Please sign in to comment.