WebWizard: Show db resource config right after choosing db as auth type
refs #8709
This commit is contained in:
parent
aecfb2eb97
commit
f615db01fe
|
@ -52,8 +52,9 @@ class MonitoringWizard extends Wizard implements SetupWizard
|
|||
$this->getDirection() === static::FORWARD
|
||||
&& ($page->getName() === 'setup_monitoring_ido' || $page->getName() === 'setup_monitoring_livestatus')
|
||||
) {
|
||||
if ((($dbResourceData = $this->getPageData('setup_db_resource')) !== null
|
||||
&& $dbResourceData['name'] === $request->getPost('name'))
|
||||
if (
|
||||
(($authDbResourceData = $this->getPageData('setup_auth_db_resource')) !== null
|
||||
&& $authDbResourceData['name'] === $request->getPost('name'))
|
||||
|| (($ldapResourceData = $this->getPageData('setup_ldap_resource')) !== null
|
||||
&& $ldapResourceData['name'] === $request->getPost('name'))
|
||||
) {
|
||||
|
|
|
@ -38,7 +38,6 @@ class DatabaseCreationPage extends Form
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->setName('setup_database_creation');
|
||||
$this->setTitle($this->translate('Database Setup', 'setup.page.title'));
|
||||
$this->addDescription($this->translate(
|
||||
'It seems that either the database you defined earlier does not yet exist and cannot be created'
|
||||
|
|
|
@ -18,7 +18,6 @@ class DbResourcePage extends Form
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->setName('setup_db_resource');
|
||||
$this->setTitle($this->translate('Database Resource', 'setup.page.title'));
|
||||
$this->addDescription($this->translate(
|
||||
'Now please configure your database resource. Note that the database itself does not need to'
|
||||
|
|
|
@ -100,14 +100,14 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$this->addPage(new RequirementsPage());
|
||||
$this->addPage(new AuthenticationPage());
|
||||
$this->addPage(new PreferencesPage());
|
||||
$this->addPage(new DbResourcePage());
|
||||
$this->addPage(new DbResourcePage(array('name' => 'setup_auth_db_resource')));
|
||||
$this->addPage(new DatabaseCreationPage(array('name' => 'setup_auth_db_creation')));
|
||||
$this->addPage(new LdapDiscoveryPage());
|
||||
//$this->addPage(new LdapDiscoveryConfirmPage());
|
||||
$this->addPage(new LdapResourcePage());
|
||||
$this->addPage(new AuthBackendPage());
|
||||
$this->addPage(new AdminAccountPage());
|
||||
$this->addPage(new GeneralConfigPage());
|
||||
$this->addPage(new DatabaseCreationPage());
|
||||
$this->addPage(new SummaryPage(array('name' => 'setup_summary')));
|
||||
|
||||
if (($modulePageData = $this->getPageData('setup_modules')) !== null) {
|
||||
|
@ -137,7 +137,7 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
} elseif ($page->getName() === 'setup_authentication_backend') {
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
if ($authData['type'] === 'db') {
|
||||
$page->setResourceConfig($this->getPageData('setup_db_resource'));
|
||||
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||
} elseif ($authData['type'] === 'ldap') {
|
||||
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
||||
|
||||
|
@ -152,34 +152,20 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$page->setBackendConfig($this->getPageData('setup_authentication_backend'));
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
if ($authData['type'] === 'db') {
|
||||
$page->setResourceConfig($this->getPageData('setup_db_resource'));
|
||||
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||
} elseif ($authData['type'] === 'ldap') {
|
||||
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
||||
}
|
||||
} elseif ($page->getName() === 'setup_database_creation') {
|
||||
} elseif ($page->getName() === 'setup_auth_db_creation') {
|
||||
$page->setDatabaseSetupPrivileges(
|
||||
array_unique(array_merge($this->databaseCreationPrivileges, $this->databaseSetupPrivileges))
|
||||
);
|
||||
$page->setDatabaseUsagePrivileges($this->databaseUsagePrivileges);
|
||||
$page->setResourceConfig($this->getPageData('setup_db_resource'));
|
||||
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||
} elseif ($page->getName() === 'setup_summary') {
|
||||
$page->setSubjectTitle('Icinga Web 2');
|
||||
$page->setSummary($this->getSetup()->getSummary());
|
||||
} elseif ($page->getName() === 'setup_db_resource') {
|
||||
$ldapData = $this->getPageData('setup_ldap_resource');
|
||||
if ($ldapData !== null && $request->getPost('name') === $ldapData['name']) {
|
||||
$page->addError(
|
||||
mt('setup', 'The given resource name must be unique and is already in use by the LDAP resource')
|
||||
);
|
||||
}
|
||||
} elseif ($page->getName() === 'setup_ldap_resource') {
|
||||
$dbData = $this->getPageData('setup_db_resource');
|
||||
if ($dbData !== null && $request->getPost('name') === $dbData['name']) {
|
||||
$page->addError(
|
||||
mt('setup', 'The given resource name must be unique and is already in use by the database resource')
|
||||
);
|
||||
}
|
||||
|
||||
$suggestion = $this->getPageData('setup_ldap_discovery');
|
||||
if (isset($suggestion['resource'])) {
|
||||
$page->populate($suggestion['resource']);
|
||||
|
@ -192,6 +178,11 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$pageData = & $this->getPageData();
|
||||
unset($pageData['setup_admin_account']);
|
||||
unset($pageData['setup_authentication_backend']);
|
||||
|
||||
if ($authData['type'] === 'db') {
|
||||
unset($pageData['setup_auth_db_resource']);
|
||||
unset($pageData['setup_auth_db_creation']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +194,7 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
{
|
||||
$skip = false;
|
||||
$newPage = parent::getNewPage($requestedPage, $originPage);
|
||||
if ($newPage->getName() === 'setup_db_resource') {
|
||||
if ($newPage->getName() === 'setup_auth_db_resource') {
|
||||
$prefData = $this->getPageData('setup_preferences_type');
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
$skip = $prefData['store'] !== 'db' && $authData['type'] !== 'db';
|
||||
|
@ -215,8 +206,8 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
} elseif ($newPage->getName() === 'setup_ldap_resource') {
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
$skip = $authData['type'] !== 'ldap';
|
||||
} elseif ($newPage->getName() === 'setup_database_creation') {
|
||||
if (($config = $this->getPageData('setup_db_resource')) !== null && ! $config['skip_validation']) {
|
||||
} elseif ($newPage->getName() === 'setup_auth_db_creation') {
|
||||
if (($config = $this->getPageData('setup_auth_db_resource')) !== null && !$config['skip_validation']) {
|
||||
$db = new DbTool($config);
|
||||
|
||||
try {
|
||||
|
@ -290,22 +281,22 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$pageData = $this->getPageData();
|
||||
$setup = new Setup();
|
||||
|
||||
if (isset($pageData['setup_db_resource'])
|
||||
&& ! $pageData['setup_db_resource']['skip_validation']
|
||||
&& (false === isset($pageData['setup_database_creation'])
|
||||
|| ! $pageData['setup_database_creation']['skip_validation']
|
||||
if (isset($pageData['setup_auth_db_resource'])
|
||||
&& !$pageData['setup_auth_db_resource']['skip_validation']
|
||||
&& (! isset($pageData['setup_auth_db_creation'])
|
||||
|| !$pageData['setup_auth_db_creation']['skip_validation']
|
||||
)
|
||||
) {
|
||||
$setup->addStep(
|
||||
new DatabaseStep(array(
|
||||
'tables' => $this->databaseTables,
|
||||
'privileges' => $this->databaseUsagePrivileges,
|
||||
'resourceConfig' => $pageData['setup_db_resource'],
|
||||
'adminName' => isset($pageData['setup_database_creation']['username'])
|
||||
? $pageData['setup_database_creation']['username']
|
||||
'resourceConfig' => $pageData['setup_auth_db_resource'],
|
||||
'adminName' => isset($pageData['setup_auth_db_creation']['username'])
|
||||
? $pageData['setup_auth_db_creation']['username']
|
||||
: null,
|
||||
'adminPassword' => isset($pageData['setup_database_creation']['password'])
|
||||
? $pageData['setup_database_creation']['password']
|
||||
'adminPassword' => isset($pageData['setup_auth_db_creation']['password'])
|
||||
? $pageData['setup_auth_db_creation']['password']
|
||||
: null,
|
||||
'schemaPath' => Config::module('setup')
|
||||
->get('schema', 'path', Icinga::app()->getBaseDir('etc' . DIRECTORY_SEPARATOR . 'schema'))
|
||||
|
@ -325,12 +316,12 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
|
||||
$adminAccountType = $pageData['setup_admin_account']['user_type'];
|
||||
$adminAccountData = array('username' => $pageData['setup_admin_account'][$adminAccountType]);
|
||||
if ($adminAccountType === 'new_user' && ! $pageData['setup_db_resource']['skip_validation']
|
||||
&& (false === isset($pageData['setup_database_creation'])
|
||||
|| ! $pageData['setup_database_creation']['skip_validation']
|
||||
if ($adminAccountType === 'new_user' && !$pageData['setup_auth_db_resource']['skip_validation']
|
||||
&& (! isset($pageData['setup_auth_db_creation'])
|
||||
|| !$pageData['setup_auth_db_creation']['skip_validation']
|
||||
)
|
||||
) {
|
||||
$adminAccountData['resourceConfig'] = $pageData['setup_db_resource'];
|
||||
$adminAccountData['resourceConfig'] = $pageData['setup_auth_db_resource'];
|
||||
$adminAccountData['password'] = $pageData['setup_admin_account']['new_user_password'];
|
||||
}
|
||||
$authType = $pageData['setup_authentication_type']['type'];
|
||||
|
@ -338,17 +329,17 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
new AuthenticationStep(array(
|
||||
'adminAccountData' => $adminAccountData,
|
||||
'backendConfig' => $pageData['setup_authentication_backend'],
|
||||
'resourceName' => $authType === 'db' ? $pageData['setup_db_resource']['name'] : (
|
||||
'resourceName' => $authType === 'db' ? $pageData['setup_auth_db_resource']['name'] : (
|
||||
$authType === 'ldap' ? $pageData['setup_ldap_resource']['name'] : null
|
||||
)
|
||||
))
|
||||
);
|
||||
|
||||
if (isset($pageData['setup_db_resource']) || isset($pageData['setup_ldap_resource'])) {
|
||||
if (isset($pageData['setup_auth_db_resource']) || isset($pageData['setup_ldap_resource'])) {
|
||||
$setup->addStep(
|
||||
new ResourceStep(array(
|
||||
'dbResourceConfig' => isset($pageData['setup_db_resource'])
|
||||
? array_diff_key($pageData['setup_db_resource'], array('skip_validation' => null))
|
||||
'dbResourceConfig' => isset($pageData['setup_auth_db_resource'])
|
||||
? array_diff_key($pageData['setup_auth_db_resource'], array('skip_validation' => null))
|
||||
: null,
|
||||
'ldapResourceConfig' => isset($pageData['setup_ldap_resource'])
|
||||
? array_diff_key($pageData['setup_ldap_resource'], array('skip_validation' => null))
|
||||
|
|
Loading…
Reference in New Issue