mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
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
|
$this->getDirection() === static::FORWARD
|
||||||
&& ($page->getName() === 'setup_monitoring_ido' || $page->getName() === 'setup_monitoring_livestatus')
|
&& ($page->getName() === 'setup_monitoring_ido' || $page->getName() === 'setup_monitoring_livestatus')
|
||||||
) {
|
) {
|
||||||
if ((($dbResourceData = $this->getPageData('setup_db_resource')) !== null
|
if (
|
||||||
&& $dbResourceData['name'] === $request->getPost('name'))
|
(($authDbResourceData = $this->getPageData('setup_auth_db_resource')) !== null
|
||||||
|
&& $authDbResourceData['name'] === $request->getPost('name'))
|
||||||
|| (($ldapResourceData = $this->getPageData('setup_ldap_resource')) !== null
|
|| (($ldapResourceData = $this->getPageData('setup_ldap_resource')) !== null
|
||||||
&& $ldapResourceData['name'] === $request->getPost('name'))
|
&& $ldapResourceData['name'] === $request->getPost('name'))
|
||||||
) {
|
) {
|
||||||
|
@ -38,7 +38,6 @@ class DatabaseCreationPage extends Form
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setName('setup_database_creation');
|
|
||||||
$this->setTitle($this->translate('Database Setup', 'setup.page.title'));
|
$this->setTitle($this->translate('Database Setup', 'setup.page.title'));
|
||||||
$this->addDescription($this->translate(
|
$this->addDescription($this->translate(
|
||||||
'It seems that either the database you defined earlier does not yet exist and cannot be created'
|
'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()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setName('setup_db_resource');
|
|
||||||
$this->setTitle($this->translate('Database Resource', 'setup.page.title'));
|
$this->setTitle($this->translate('Database Resource', 'setup.page.title'));
|
||||||
$this->addDescription($this->translate(
|
$this->addDescription($this->translate(
|
||||||
'Now please configure your database resource. Note that the database itself does not need to'
|
'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 RequirementsPage());
|
||||||
$this->addPage(new AuthenticationPage());
|
$this->addPage(new AuthenticationPage());
|
||||||
$this->addPage(new PreferencesPage());
|
$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 LdapDiscoveryPage());
|
||||||
//$this->addPage(new LdapDiscoveryConfirmPage());
|
//$this->addPage(new LdapDiscoveryConfirmPage());
|
||||||
$this->addPage(new LdapResourcePage());
|
$this->addPage(new LdapResourcePage());
|
||||||
$this->addPage(new AuthBackendPage());
|
$this->addPage(new AuthBackendPage());
|
||||||
$this->addPage(new AdminAccountPage());
|
$this->addPage(new AdminAccountPage());
|
||||||
$this->addPage(new GeneralConfigPage());
|
$this->addPage(new GeneralConfigPage());
|
||||||
$this->addPage(new DatabaseCreationPage());
|
|
||||||
$this->addPage(new SummaryPage(array('name' => 'setup_summary')));
|
$this->addPage(new SummaryPage(array('name' => 'setup_summary')));
|
||||||
|
|
||||||
if (($modulePageData = $this->getPageData('setup_modules')) !== null) {
|
if (($modulePageData = $this->getPageData('setup_modules')) !== null) {
|
||||||
@ -137,7 +137,7 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
} elseif ($page->getName() === 'setup_authentication_backend') {
|
} elseif ($page->getName() === 'setup_authentication_backend') {
|
||||||
$authData = $this->getPageData('setup_authentication_type');
|
$authData = $this->getPageData('setup_authentication_type');
|
||||||
if ($authData['type'] === 'db') {
|
if ($authData['type'] === 'db') {
|
||||||
$page->setResourceConfig($this->getPageData('setup_db_resource'));
|
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||||
} elseif ($authData['type'] === 'ldap') {
|
} elseif ($authData['type'] === 'ldap') {
|
||||||
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
||||||
|
|
||||||
@ -152,34 +152,20 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
$page->setBackendConfig($this->getPageData('setup_authentication_backend'));
|
$page->setBackendConfig($this->getPageData('setup_authentication_backend'));
|
||||||
$authData = $this->getPageData('setup_authentication_type');
|
$authData = $this->getPageData('setup_authentication_type');
|
||||||
if ($authData['type'] === 'db') {
|
if ($authData['type'] === 'db') {
|
||||||
$page->setResourceConfig($this->getPageData('setup_db_resource'));
|
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||||
} elseif ($authData['type'] === 'ldap') {
|
} elseif ($authData['type'] === 'ldap') {
|
||||||
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
||||||
}
|
}
|
||||||
} elseif ($page->getName() === 'setup_database_creation') {
|
} elseif ($page->getName() === 'setup_auth_db_creation') {
|
||||||
$page->setDatabaseSetupPrivileges(
|
$page->setDatabaseSetupPrivileges(
|
||||||
array_unique(array_merge($this->databaseCreationPrivileges, $this->databaseSetupPrivileges))
|
array_unique(array_merge($this->databaseCreationPrivileges, $this->databaseSetupPrivileges))
|
||||||
);
|
);
|
||||||
$page->setDatabaseUsagePrivileges($this->databaseUsagePrivileges);
|
$page->setDatabaseUsagePrivileges($this->databaseUsagePrivileges);
|
||||||
$page->setResourceConfig($this->getPageData('setup_db_resource'));
|
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||||
} elseif ($page->getName() === 'setup_summary') {
|
} elseif ($page->getName() === 'setup_summary') {
|
||||||
$page->setSubjectTitle('Icinga Web 2');
|
$page->setSubjectTitle('Icinga Web 2');
|
||||||
$page->setSummary($this->getSetup()->getSummary());
|
$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') {
|
} 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');
|
$suggestion = $this->getPageData('setup_ldap_discovery');
|
||||||
if (isset($suggestion['resource'])) {
|
if (isset($suggestion['resource'])) {
|
||||||
$page->populate($suggestion['resource']);
|
$page->populate($suggestion['resource']);
|
||||||
@ -192,6 +178,11 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
$pageData = & $this->getPageData();
|
$pageData = & $this->getPageData();
|
||||||
unset($pageData['setup_admin_account']);
|
unset($pageData['setup_admin_account']);
|
||||||
unset($pageData['setup_authentication_backend']);
|
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;
|
$skip = false;
|
||||||
$newPage = parent::getNewPage($requestedPage, $originPage);
|
$newPage = parent::getNewPage($requestedPage, $originPage);
|
||||||
if ($newPage->getName() === 'setup_db_resource') {
|
if ($newPage->getName() === 'setup_auth_db_resource') {
|
||||||
$prefData = $this->getPageData('setup_preferences_type');
|
$prefData = $this->getPageData('setup_preferences_type');
|
||||||
$authData = $this->getPageData('setup_authentication_type');
|
$authData = $this->getPageData('setup_authentication_type');
|
||||||
$skip = $prefData['store'] !== 'db' && $authData['type'] !== 'db';
|
$skip = $prefData['store'] !== 'db' && $authData['type'] !== 'db';
|
||||||
@ -215,8 +206,8 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
} elseif ($newPage->getName() === 'setup_ldap_resource') {
|
} elseif ($newPage->getName() === 'setup_ldap_resource') {
|
||||||
$authData = $this->getPageData('setup_authentication_type');
|
$authData = $this->getPageData('setup_authentication_type');
|
||||||
$skip = $authData['type'] !== 'ldap';
|
$skip = $authData['type'] !== 'ldap';
|
||||||
} elseif ($newPage->getName() === 'setup_database_creation') {
|
} elseif ($newPage->getName() === 'setup_auth_db_creation') {
|
||||||
if (($config = $this->getPageData('setup_db_resource')) !== null && ! $config['skip_validation']) {
|
if (($config = $this->getPageData('setup_auth_db_resource')) !== null && !$config['skip_validation']) {
|
||||||
$db = new DbTool($config);
|
$db = new DbTool($config);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -290,22 +281,22 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
$pageData = $this->getPageData();
|
$pageData = $this->getPageData();
|
||||||
$setup = new Setup();
|
$setup = new Setup();
|
||||||
|
|
||||||
if (isset($pageData['setup_db_resource'])
|
if (isset($pageData['setup_auth_db_resource'])
|
||||||
&& ! $pageData['setup_db_resource']['skip_validation']
|
&& !$pageData['setup_auth_db_resource']['skip_validation']
|
||||||
&& (false === isset($pageData['setup_database_creation'])
|
&& (! isset($pageData['setup_auth_db_creation'])
|
||||||
|| ! $pageData['setup_database_creation']['skip_validation']
|
|| !$pageData['setup_auth_db_creation']['skip_validation']
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$setup->addStep(
|
$setup->addStep(
|
||||||
new DatabaseStep(array(
|
new DatabaseStep(array(
|
||||||
'tables' => $this->databaseTables,
|
'tables' => $this->databaseTables,
|
||||||
'privileges' => $this->databaseUsagePrivileges,
|
'privileges' => $this->databaseUsagePrivileges,
|
||||||
'resourceConfig' => $pageData['setup_db_resource'],
|
'resourceConfig' => $pageData['setup_auth_db_resource'],
|
||||||
'adminName' => isset($pageData['setup_database_creation']['username'])
|
'adminName' => isset($pageData['setup_auth_db_creation']['username'])
|
||||||
? $pageData['setup_database_creation']['username']
|
? $pageData['setup_auth_db_creation']['username']
|
||||||
: null,
|
: null,
|
||||||
'adminPassword' => isset($pageData['setup_database_creation']['password'])
|
'adminPassword' => isset($pageData['setup_auth_db_creation']['password'])
|
||||||
? $pageData['setup_database_creation']['password']
|
? $pageData['setup_auth_db_creation']['password']
|
||||||
: null,
|
: null,
|
||||||
'schemaPath' => Config::module('setup')
|
'schemaPath' => Config::module('setup')
|
||||||
->get('schema', 'path', Icinga::app()->getBaseDir('etc' . DIRECTORY_SEPARATOR . 'schema'))
|
->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'];
|
$adminAccountType = $pageData['setup_admin_account']['user_type'];
|
||||||
$adminAccountData = array('username' => $pageData['setup_admin_account'][$adminAccountType]);
|
$adminAccountData = array('username' => $pageData['setup_admin_account'][$adminAccountType]);
|
||||||
if ($adminAccountType === 'new_user' && ! $pageData['setup_db_resource']['skip_validation']
|
if ($adminAccountType === 'new_user' && !$pageData['setup_auth_db_resource']['skip_validation']
|
||||||
&& (false === isset($pageData['setup_database_creation'])
|
&& (! isset($pageData['setup_auth_db_creation'])
|
||||||
|| ! $pageData['setup_database_creation']['skip_validation']
|
|| !$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'];
|
$adminAccountData['password'] = $pageData['setup_admin_account']['new_user_password'];
|
||||||
}
|
}
|
||||||
$authType = $pageData['setup_authentication_type']['type'];
|
$authType = $pageData['setup_authentication_type']['type'];
|
||||||
@ -338,17 +329,17 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
new AuthenticationStep(array(
|
new AuthenticationStep(array(
|
||||||
'adminAccountData' => $adminAccountData,
|
'adminAccountData' => $adminAccountData,
|
||||||
'backendConfig' => $pageData['setup_authentication_backend'],
|
'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
|
$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(
|
$setup->addStep(
|
||||||
new ResourceStep(array(
|
new ResourceStep(array(
|
||||||
'dbResourceConfig' => isset($pageData['setup_db_resource'])
|
'dbResourceConfig' => isset($pageData['setup_auth_db_resource'])
|
||||||
? array_diff_key($pageData['setup_db_resource'], array('skip_validation' => null))
|
? array_diff_key($pageData['setup_auth_db_resource'], array('skip_validation' => null))
|
||||||
: null,
|
: null,
|
||||||
'ldapResourceConfig' => isset($pageData['setup_ldap_resource'])
|
'ldapResourceConfig' => isset($pageData['setup_ldap_resource'])
|
||||||
? array_diff_key($pageData['setup_ldap_resource'], array('skip_validation' => null))
|
? array_diff_key($pageData['setup_ldap_resource'], array('skip_validation' => null))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user