+// Load CiviCRM database config
+if (isset($_POST['mysql'])) {
+ $databaseConfig = $_POST['mysql'];
+}
+
+if ($installType == 'wordpress') {
+ // Load WP database config
+ if (isset($_POST['mysql'])) {
+ $databaseConfig = $_POST['mysql'];
+ }
+ else {
+ $databaseConfig = array(
+ "server" => DB_HOST,
+ "username" => DB_USER,
+ "password" => DB_PASSWORD,
+ "database" => DB_NAME,
+ );
+ }
+}
+
+if ($installType == 'drupal') {
+ // Load drupal database config
+ if (isset($_POST['drupal'])) {
+ $drupalConfig = $_POST['drupal'];
+ }
+ else {
+ $dbServer = $databases['default']['default']['host'];
+ if (!empty($databases['default']['default']['port'])) {
+ $dbServer .= ':' . $databases['default']['default']['port'];
+ }
+ $drupalConfig = array(
+ "server" => $dbServer,
+ "username" => $databases['default']['default']['username'],
+ "password" => $databases['default']['default']['password'],
+ "database" => $databases['default']['default']['database'],
+ );
+ }
+}
+
+if ($installType == 'backdrop') {
+ // Load backdrop database config
+ if (isset($_POST['backdrop'])) {
+ $backdropConfig = $_POST['backdrop'];
+ }
+ else {
+ $backdropConfig = array(
+ "server" => "localhost",
+ "username" => "backdrop",
+ "password" => "",
+ "database" => "backdrop",
+ );
+ }
+}
+
+// By default set CiviCRM database to be same as CMS database
+if (!isset($databaseConfig)) {
+ if (($installType == 'drupal') && (isset($drupalConfig))) {
+ $databaseConfig = $drupalConfig;
+ }
+ if (($installType == 'backdrop') && (isset($backdropConfig))) {
+ $databaseConfig = $backdropConfig;
+ }
+}
+