protected function database($submissionVars)
{
$formVars = array('dbuser' => array('type' => 'text', 'value' => '', 'required' => TRUE), 'dbpassword' => array('type' => 'password', 'value' => '', 'required' => FALSE), 'dbname' => array('type' => 'text', 'value' => '', 'required' => TRUE), 'dbhost' => array('type' => 'text', 'value' => 'localhost', 'required' => TRUE), 'dbprefix' => array('type' => 'text', 'value' => 'elgg_', 'required' => TRUE), 'timezone' => array('type' => 'dropdown', 'value' => 'UTC', 'options' => \DateTimeZone::listIdentifiers(), 'required' => TRUE));
if ($this->checkSettingsFile()) {
// user manually created settings file so we fake out action test
$this->isAction = TRUE;
}
if ($this->isAction) {
do {
// only create settings file if it doesn't exist
if (!$this->checkSettingsFile()) {
if (!$this->validateDatabaseVars($submissionVars, $formVars)) {
// error so we break out of action and serve same page
break;
}
if (!$this->createSettingsFile($submissionVars)) {
break;
}
}
// check db version and connect
if (!$this->connectToDatabase()) {
break;
}
if (!$this->installDatabase()) {
break;
}
system_message(_elgg_services()->translator->translate('install:success:database'));
$this->continueToNextStep('database');
} while (FALSE);
// PHP doesn't support breaking out of if statements
}
$formVars = $this->makeFormSticky($formVars, $submissionVars);
$params = array('variables' => $formVars);
if ($this->checkSettingsFile()) {
// settings file exists and we're here so failed to create database
$params['failure'] = TRUE;
}
$this->render('database', $params);
}