From: skodak Date: Sat, 7 Feb 2009 17:07:05 +0000 (+0000) Subject: MDL-18167 more hooks for distros X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6724b0598b007dc168d0524aaa6966a2a2625148;p=moodle.git MDL-18167 more hooks for distros --- diff --git a/install.php b/install.php index a3a36bd883..f0faa531a5 100644 --- a/install.php +++ b/install.php @@ -93,8 +93,8 @@ if (!empty($_POST)) { $config->stage = INSTALL_WELCOME; $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection - $config->dbhost = 'localhost'; - $config->dbuser = ''; + $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost + $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser $config->dbpass = ''; $config->dbname = 'moodle'; $config->prefix = 'mdl_'; @@ -195,7 +195,7 @@ if ($config->stage == INSTALL_SAVE) { if (!$database->driver_installed()) { $config->stage = INSTALL_DATABASETYPE; } else { - $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersit'=>0, 'dbsocket'=>$config->dbsocket)); + $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersit'=>0, 'dbsocket'=>$config->dbsocket), $distro); if ($hint_database === '') { $configphp = 'stage == INSTALL_DATABASE) { $strdbsocket = get_string('databasesocket', 'install'); echo '
'; + + $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled'; echo '
'; - echo ''; + echo ''; echo '
'; echo '
'; echo ''; echo '
'; + $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled'; echo '
'; - echo ''; + echo ''; echo '
'; echo '
'; diff --git a/lib/installlib.php b/lib/installlib.php index 4797cb7d85..49a0cfc963 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -57,8 +57,22 @@ function install_helpbutton($url, $title='') { echo "\n"; } -function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions) { +function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions, $distro) { // this is in function because we want the /install.php to parse in PHP4 + + if ($database->get_dbfamily() === 'mysql' and !empty($distro->setdbrootpassword) and $dbpass !== '') { + // distro hack - set root password + try { + if ($database->connect($dbhost, $dbuser, '', $dbname, $prefix, $dboptions)) { + $sql = "UPDATE user SET password=password(?) WHERE user='root'"; + $params = array($dbpass); + $database->execute($sql, $params); + return ''; + } + } catch (Exception $ignored) { + } + } + try { try { $database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);