WebWizard: Drop preferences page and include ApplicationConfigForm instead
refs #8709
This commit is contained in:
parent
066b3d9e28
commit
7795ad4f95
|
@ -55,8 +55,10 @@ class MonitoringWizard extends Wizard implements SetupWizard
|
|||
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'))
|
||||
|| (($configDbResourceData = $this->getPageData('setup_config_db_resource')) !== null
|
||||
&& $configDbResourceData['name'] === $request->getPost('name'))
|
||||
|| (($ldapResourceData = $this->getPageData('setup_ldap_resource')) !== null
|
||||
&& $ldapResourceData['name'] === $request->getPost('name'))
|
||||
) {
|
||||
$page->addError(mt('monitoring', 'The given resource name is already in use.'));
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
namespace Icinga\Module\Setup\Forms;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Forms\Config\General\ApplicationConfigForm;
|
||||
use Icinga\Forms\Config\General\LoggingConfigForm;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
* Wizard page to define the application and logging configuration
|
||||
|
@ -28,7 +29,13 @@ class GeneralConfigPage extends Form
|
|||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
$loggingForm = new LoggingConfigForm();
|
||||
$this->addElements($loggingForm->createElements($formData)->getElements());
|
||||
$appConfigForm = new ApplicationConfigForm();
|
||||
$appConfigForm->createElements($formData);
|
||||
$appConfigForm->removeElement('global_module_path');
|
||||
$appConfigForm->removeElement('global_config_resource');
|
||||
$this->addElements($appConfigForm->getElements());
|
||||
|
||||
$loggingConfigForm = new LoggingConfigForm();
|
||||
$this->addElements($loggingConfigForm->createElements($formData)->getElements());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Setup\Forms;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Application\Platform;
|
||||
|
||||
/**
|
||||
* Wizard page to choose a preference backend
|
||||
*/
|
||||
class PreferencesPage extends Form
|
||||
{
|
||||
/**
|
||||
* Initialize this page
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->setRequiredCue(null);
|
||||
$this->setName('setup_preferences_type');
|
||||
$this->setTitle($this->translate('Preferences', 'setup.page.title'));
|
||||
$this->addDescription($this->translate('Please choose how Icinga Web 2 should store user preferences.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Form::createElements()
|
||||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
$storageTypes = array();
|
||||
$storageTypes['ini'] = $this->translate('File System (INI Files)');
|
||||
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
|
||||
$storageTypes['db'] = $this->translate('Database');
|
||||
}
|
||||
$storageTypes['none'] = $this->translate('Don\'t Store Preferences');
|
||||
|
||||
$this->addElement(
|
||||
'select',
|
||||
'store',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => $this->translate('User Preference Storage Type'),
|
||||
'multiOptions' => $storageTypes
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -23,13 +23,12 @@ class GeneralConfigStep extends Step
|
|||
{
|
||||
$config = array();
|
||||
foreach ($this->data['generalConfig'] as $sectionAndPropertyName => $value) {
|
||||
list($section, $property) = explode('_', $sectionAndPropertyName);
|
||||
list($section, $property) = explode('_', $sectionAndPropertyName, 2);
|
||||
$config[$section][$property] = $value;
|
||||
}
|
||||
|
||||
$config['preferences']['store'] = $this->data['preferencesStore'];
|
||||
if (isset($this->data['preferencesResource'])) {
|
||||
$config['preferences']['resource'] = $this->data['preferencesResource'];
|
||||
if ($config['global']['config_backend'] === 'db') {
|
||||
$config['global']['config_resource'] = $this->data['resourceName'];
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -54,14 +53,10 @@ class GeneralConfigStep extends Step
|
|||
$generalHtml = ''
|
||||
. '<ul>'
|
||||
. '<li>' . sprintf(
|
||||
$this->data['preferencesStore'] === 'ini' ? sprintf(
|
||||
$this->data['generalConfig']['global_config_backend'] === 'ini' ? sprintf(
|
||||
t('Preferences will be stored per user account in INI files at: %s'),
|
||||
Config::resolvePath('preferences')
|
||||
) : (
|
||||
$this->data['preferencesStore'] === 'db' ? t('Preferences will be stored using a database.') : (
|
||||
t('Preferences will not be persisted across browser sessions.')
|
||||
)
|
||||
)
|
||||
) : t('Preferences will be stored using a database.')
|
||||
) . '</li>'
|
||||
. '</ul>';
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ use Icinga\Module\Setup\Forms\ModulePage;
|
|||
use Icinga\Module\Setup\Forms\WelcomePage;
|
||||
use Icinga\Module\Setup\Forms\SummaryPage;
|
||||
use Icinga\Module\Setup\Forms\DbResourcePage;
|
||||
use Icinga\Module\Setup\Forms\PreferencesPage;
|
||||
use Icinga\Module\Setup\Forms\AuthBackendPage;
|
||||
use Icinga\Module\Setup\Forms\AdminAccountPage;
|
||||
use Icinga\Module\Setup\Forms\LdapDiscoveryPage;
|
||||
|
@ -99,7 +98,6 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$this->addPage(new ModulePage());
|
||||
$this->addPage(new RequirementsPage());
|
||||
$this->addPage(new AuthenticationPage());
|
||||
$this->addPage(new PreferencesPage());
|
||||
$this->addPage(new DbResourcePage(array('name' => 'setup_auth_db_resource')));
|
||||
$this->addPage(new DatabaseCreationPage(array('name' => 'setup_auth_db_creation')));
|
||||
$this->addPage(new LdapDiscoveryPage());
|
||||
|
@ -108,6 +106,8 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$this->addPage(new AuthBackendPage());
|
||||
$this->addPage(new AdminAccountPage());
|
||||
$this->addPage(new GeneralConfigPage());
|
||||
$this->addPage(new DbResourcePage(array('name' => 'setup_config_db_resource')));
|
||||
$this->addPage(new DatabaseCreationPage(array('name' => 'setup_config_db_creation')));
|
||||
$this->addPage(new SummaryPage(array('name' => 'setup_summary')));
|
||||
|
||||
if (($modulePageData = $this->getPageData('setup_modules')) !== null) {
|
||||
|
@ -125,15 +125,6 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
{
|
||||
if ($page->getName() === 'setup_requirements') {
|
||||
$page->setWizard($this);
|
||||
} elseif ($page->getName() === 'setup_preferences_type') {
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
if ($authData['type'] === 'db') {
|
||||
$page->create()->getElement('store')->setValue('db');
|
||||
$page->addDescription(mt(
|
||||
'setup',
|
||||
'Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.'
|
||||
));
|
||||
}
|
||||
} elseif ($page->getName() === 'setup_authentication_backend') {
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
if ($authData['type'] === 'db') {
|
||||
|
@ -156,20 +147,42 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
} elseif ($authData['type'] === 'ldap') {
|
||||
$page->setResourceConfig($this->getPageData('setup_ldap_resource'));
|
||||
}
|
||||
} elseif ($page->getName() === 'setup_auth_db_creation') {
|
||||
} elseif ($page->getName() === 'setup_auth_db_creation' || $page->getName() === 'setup_config_db_creation') {
|
||||
$page->setDatabaseSetupPrivileges(
|
||||
array_unique(array_merge($this->databaseCreationPrivileges, $this->databaseSetupPrivileges))
|
||||
);
|
||||
$page->setDatabaseUsagePrivileges($this->databaseUsagePrivileges);
|
||||
$page->setResourceConfig($this->getPageData('setup_auth_db_resource'));
|
||||
$page->setResourceConfig(
|
||||
$this->getPageData('setup_auth_db_resource') ?: $this->getPageData('setup_config_db_resource')
|
||||
);
|
||||
} elseif ($page->getName() === 'setup_summary') {
|
||||
$page->setSubjectTitle('Icinga Web 2');
|
||||
$page->setSummary($this->getSetup()->getSummary());
|
||||
} elseif ($page->getName() === 'setup_config_db_resource') {
|
||||
$ldapData = $this->getPageData('setup_ldap_resource');
|
||||
if ($ldapData !== null && $request->getPost('name') === $ldapData['name']) {
|
||||
$page->error(
|
||||
mt('setup', 'The given resource name must be unique and is already in use by the LDAP resource')
|
||||
);
|
||||
}
|
||||
} elseif ($page->getName() === 'setup_ldap_resource') {
|
||||
$suggestion = $this->getPageData('setup_ldap_discovery');
|
||||
if (isset($suggestion['resource'])) {
|
||||
$page->populate($suggestion['resource']);
|
||||
}
|
||||
} elseif ($page->getName() === 'setup_general_config') {
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
if ($authData['type'] === 'db') {
|
||||
$page->create()->getElement('global_config_backend')->setValue('db');
|
||||
$page->info(
|
||||
mt(
|
||||
'setup',
|
||||
'Note that choosing "Database" as preference storage causes'
|
||||
. ' Icinga Web 2 to use the same database as for authentication.'
|
||||
),
|
||||
false
|
||||
);
|
||||
}
|
||||
} elseif ($page->getName() === 'setup_authentication_type' && $this->getDirection() === static::FORWARD) {
|
||||
$authData = $this->getPageData($page->getName());
|
||||
if ($authData !== null && $request->getPost('type') !== $authData['type']) {
|
||||
|
@ -182,6 +195,9 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
if ($authData['type'] === 'db') {
|
||||
unset($pageData['setup_auth_db_resource']);
|
||||
unset($pageData['setup_auth_db_creation']);
|
||||
} elseif ($request->getPost('type') === 'db') {
|
||||
unset($pageData['setup_config_db_resource']);
|
||||
unset($pageData['setup_config_db_creation']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,9 +211,8 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$skip = false;
|
||||
$newPage = parent::getNewPage($requestedPage, $originPage);
|
||||
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';
|
||||
$skip = $authData['type'] !== 'db';
|
||||
} elseif ($newPage->getname() === 'setup_ldap_discovery') {
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
$skip = $authData['type'] !== 'ldap';
|
||||
|
@ -206,8 +221,16 @@ 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_auth_db_creation') {
|
||||
if (($config = $this->getPageData('setup_auth_db_resource')) !== null && !$config['skip_validation']) {
|
||||
} elseif ($newPage->getName() === 'setup_config_db_resource') {
|
||||
$authData = $this->getPageData('setup_authentication_type');
|
||||
$skip = $authData['type'] === 'db';
|
||||
} elseif (in_array($newPage->getName(), array('setup_auth_db_creation', 'setup_config_db_creation'))) {
|
||||
if (
|
||||
($newPage->getName() === 'setup_auth_db_creation' || $this->hasPageData('setup_config_db_resource'))
|
||||
&& (($config = $this->getPageData('setup_auth_db_resource')) !== null
|
||||
|| ($config = $this->getPageData('setup_config_db_resource')) !== null)
|
||||
&& !$config['skip_validation']
|
||||
) {
|
||||
$db = new DbTool($config);
|
||||
|
||||
try {
|
||||
|
@ -281,7 +304,8 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
$pageData = $this->getPageData();
|
||||
$setup = new Setup();
|
||||
|
||||
if (isset($pageData['setup_auth_db_resource'])
|
||||
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']
|
||||
|
@ -302,15 +326,39 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
->get('schema', 'path', Icinga::app()->getBaseDir('etc' . DIRECTORY_SEPARATOR . 'schema'))
|
||||
))
|
||||
);
|
||||
} elseif (
|
||||
isset($pageData['setup_config_db_resource'])
|
||||
&& !$pageData['setup_config_db_resource']['skip_validation']
|
||||
&& (! isset($pageData['setup_config_db_creation'])
|
||||
|| !$pageData['setup_config_db_creation']['skip_validation']
|
||||
)
|
||||
) {
|
||||
$setup->addStep(
|
||||
new DatabaseStep(array(
|
||||
'tables' => $this->databaseTables,
|
||||
'privileges' => $this->databaseUsagePrivileges,
|
||||
'resourceConfig' => $pageData['setup_config_db_resource'],
|
||||
'adminName' => isset($pageData['setup_config_db_creation']['username'])
|
||||
? $pageData['setup_config_db_creation']['username']
|
||||
: null,
|
||||
'adminPassword' => isset($pageData['setup_config_db_creation']['password'])
|
||||
? $pageData['setup_config_db_creation']['password']
|
||||
: null,
|
||||
'schemaPath' => Config::module('setup')
|
||||
->get('schema', 'path', Icinga::app()->getBaseDir('etc' . DIRECTORY_SEPARATOR . 'schema'))
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
$setup->addStep(
|
||||
new GeneralConfigStep(array(
|
||||
'generalConfig' => $pageData['setup_general_config'],
|
||||
'preferencesStore' => $pageData['setup_preferences_type']['store'],
|
||||
'preferencesResource' => isset($pageData['setup_db_resource']['name'])
|
||||
? $pageData['setup_db_resource']['name']
|
||||
: null
|
||||
'generalConfig' => $pageData['setup_general_config'],
|
||||
'resourceName' => isset($pageData['setup_auth_db_resource']['name'])
|
||||
? $pageData['setup_auth_db_resource']['name']
|
||||
: (isset($pageData['setup_config_db_resource']['name'])
|
||||
? $pageData['setup_config_db_resource']['name']
|
||||
: null
|
||||
)
|
||||
))
|
||||
);
|
||||
|
||||
|
@ -335,12 +383,19 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
))
|
||||
);
|
||||
|
||||
if (isset($pageData['setup_auth_db_resource']) || isset($pageData['setup_ldap_resource'])) {
|
||||
if (
|
||||
isset($pageData['setup_auth_db_resource'])
|
||||
|| isset($pageData['setup_config_db_resource'])
|
||||
|| isset($pageData['setup_ldap_resource'])
|
||||
) {
|
||||
$setup->addStep(
|
||||
new ResourceStep(array(
|
||||
'dbResourceConfig' => isset($pageData['setup_auth_db_resource'])
|
||||
? array_diff_key($pageData['setup_auth_db_resource'], array('skip_validation' => null))
|
||||
: null,
|
||||
: (isset($pageData['setup_config_db_resource'])
|
||||
? array_diff_key($pageData['setup_config_db_resource'], array('skip_validation' => null))
|
||||
: null
|
||||
),
|
||||
'ldapResourceConfig' => isset($pageData['setup_ldap_resource'])
|
||||
? array_diff_key($pageData['setup_ldap_resource'], array('skip_validation' => null))
|
||||
: null
|
||||
|
|
Loading…
Reference in New Issue