From a6cbde54c533a0ca69fb9812793852aa06b52423 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 23 Oct 2014 15:15:59 +0200 Subject: [PATCH] Move summary HTML generation from the view script to each install step refs #7163 --- .../views/scripts/form/setup-summary.phtml | 230 ++---------------- .../Installation/AuthenticationStep.php | 48 +++- .../Application/Installation/DatabaseStep.php | 60 ++++- .../Installation/GeneralConfigStep.php | 65 ++++- .../Application/Installation/ResourceStep.php | 79 +++++- 5 files changed, 262 insertions(+), 220 deletions(-) diff --git a/application/views/scripts/form/setup-summary.phtml b/application/views/scripts/form/setup-summary.phtml index 2cda47c177..b862aec3c3 100644 --- a/application/views/scripts/form/setup-summary.phtml +++ b/application/views/scripts/form/setup-summary.phtml @@ -1,227 +1,25 @@ getSummary(); -$prefType = $summary['setup_preferences_type']['type']; -$authType = $summary['setup_authentication_type']['type']; -$adminType = $summary['setup_admin_account']['user_type']; -$loggingType = $summary['setup_general_config']['logging_log']; ?>

- -
-

- -
-

- -

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
-

-

LDAP

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- +getSummary() as $pageHtml): ?>
-

-
-

-

- - - - - - - - - - - - - - - - - - - - - - -
-
-
-

-

-

+
-
-

-
-

-
    -
  • -
  • -
  • -
-
-
-

- -

- - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
-

-

+ +
+
+ getElement($form->getTokenElementName()); ?> + getElement($form->getUidElementName()); ?> +
+ getElement(Wizard::BTN_PREV); ?> + getElement(Wizard::BTN_NEXT)->setAttrib('class', 'install'); ?>
- - - getElement($form->getTokenElementName()); ?> - getElement($form->getUidElementName()); ?> -
- getElement(Wizard::BTN_PREV); ?> - getElement(Wizard::BTN_NEXT)->setAttrib('class', 'install'); ?> -
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/library/Icinga/Application/Installation/AuthenticationStep.php b/library/Icinga/Application/Installation/AuthenticationStep.php index 4bea703a91..73a5da671f 100644 --- a/library/Icinga/Application/Installation/AuthenticationStep.php +++ b/library/Icinga/Application/Installation/AuthenticationStep.php @@ -95,7 +95,53 @@ protected function createAccount() public function getSummary() { - return ''; + $pageTitle = '

' . t('Authentication') . '

'; + $backendTitle = '

' . t('Backend Configuration') . '

'; + $adminTitle = '

' . t('Initial Administrative Account') . '

'; + + $authType = $this->data['backendConfig']['backend']; + $backendDesc = '

' . sprintf( + t('Users will authenticate using %s.', 'setup.summary.auth'), + $authType === 'db' ? t('a database', 'setup.summary.auth.type') : ( + $authType === 'ldap' ? 'LDAP' : t('webserver authentication', 'setup.summary.auth.type') + ) + ) . '

'; + + $backendHtml = '' + . '' + . '' + . '' + . '' + . '' + . '' + . ($authType === 'ldap' ? ( + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + ) : ($authType === 'autologin' ? ( + '' + . '' + . '' + . '' + ) : '')) + . '' + . '
' . t('Backend Name') . '' . $this->data['backendConfig']['name'] . '
' . t('User Object Class') . '' . $this->data['backendConfig']['user_class'] . '
' . t('User Name Attribute') . '' . $this->data['backendConfig']['user_name_attribute'] . '
' . t('Filter Pattern') . '' . $this->data['backendConfig']['strip_username_regexp'] . '
'; + + $adminHtml = '

' . (isset($this->data['adminAccountData']['resourceConfig']) ? sprintf( + t('Administrative rights will initially be granted to an existing account called "%s".'), + $this->data['adminAccountData']['username'] + ) : sprintf( + t('Administrative rights will initially be granted to a new account called "%s".'), + $this->data['adminAccountData']['username'] + )) . '

'; + + return $pageTitle . '
' . $backendDesc . $backendTitle . $backendHtml . '
' + . '
' . $adminTitle . $adminHtml . '
'; } public function getReport() diff --git a/library/Icinga/Application/Installation/DatabaseStep.php b/library/Icinga/Application/Installation/DatabaseStep.php index 170d6ff3fb..bad9154982 100644 --- a/library/Icinga/Application/Installation/DatabaseStep.php +++ b/library/Icinga/Application/Installation/DatabaseStep.php @@ -152,7 +152,65 @@ protected function setupPgsqlDatabase(DbTool $db) public function getSummary() { - return ''; + $resourceConfig = $this->data['resourceConfig']; + if (isset($this->data['adminName'])) { + $resourceConfig['username'] = $this->data['adminName']; + if (isset($this->data['adminPassword'])) { + $resourceConfig['password'] = $this->data['adminPassword']; + } + } + + $db = new DbTool($resourceConfig); + + try { + $db->connectToDb(); + if (array_search('account', $db->listTables()) === false) { + $message = sprintf( + t( + 'The database user "%s" will be used to setup the missing' + . ' schema required by Icinga Web 2 in database "%s".' + ), + $resourceConfig['username'], + $resourceConfig['dbname'] + ); + } else { + $message = sprintf( + t('The database "%s" already seems to be fully set up. No action required.'), + $resourceConfig['dbname'] + ); + } + } catch (PDOException $e) { + try { + $db->connectToHost(); + if ($db->hasLogin($this->data['resourceConfig']['username'])) { + $message = sprintf( + t( + 'The database user "%s" will be used to create the missing ' + . 'database "%s" with the schema required by Icinga Web 2.' + ), + $resourceConfig['username'], + $resourceConfig['dbname'] + ); + } else { + $message = sprintf( + t( + 'The database user "%s" will be used to create the missing database "%s" ' + . 'with the schema required by Icinga Web 2 and a new login called "%s".' + ), + $resourceConfig['username'], + $resourceConfig['dbname'], + $this->data['resourceConfig']['username'] + ); + } + } catch (Exception $ex) { + $message = t( + 'No connection to database host possible. You\'ll need to setup the' + . ' database with the schema required by Icinga Web 2 manually.' + ); + } + } + + return '

' . t('Database Setup') . '

' . $message . '

'; } public function getReport() diff --git a/library/Icinga/Application/Installation/GeneralConfigStep.php b/library/Icinga/Application/Installation/GeneralConfigStep.php index 7277d3f1e7..47b1440528 100644 --- a/library/Icinga/Application/Installation/GeneralConfigStep.php +++ b/library/Icinga/Application/Installation/GeneralConfigStep.php @@ -6,6 +6,7 @@ use Exception; use Zend_Config; +use Icinga\Logger\Logger; use Icinga\Web\Setup\Step; use Icinga\Application\Config; use Icinga\Config\PreservingIniWriter; @@ -52,7 +53,69 @@ public function apply() public function getSummary() { - return ''; + $pageTitle = '

' . t('Application Configuration') . '

'; + $generalTitle = '

' . t('General', 'app.config') . '

'; + $loggingTitle = '

' . t('Logging', 'app.config') . '

'; + + $generalHtml = '' + . ''; + + $type = $this->data['generalConfig']['logging_log']; + if ($type === 'none') { + $loggingHtml = '

' . t('Logging will be disabled.') . '

'; + } else { + $level = $this->data['generalConfig']['logging_level']; + $loggingHtml = '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . ($type === 'syslog' ? ( + '' + . '' + ) : ( + '' + . '' + )) + . '' + . '' + . '
' . t('Type', 'app.config.logging') . '' . ($type === 'syslog' ? 'Syslog' : t('File', 'app.config.logging.type')) . '
' . t('Level', 'app.config.logging') . '' . ($level === Logger::$levels[Logger::ERROR] ? t('Error', 'app.config.logging.level') : ( + $level === Logger::$levels[Logger::WARNING] ? t('Warning', 'app.config.logging.level') : ( + $level === Logger::$levels[Logger::INFO] ? t('Information', 'app.config.logging.level') : ( + t('Debug', 'app.config.logging.level') + ) + ) + )) . '
' . t('Application Prefix') . '' . $this->data['generalConfig']['logging_application'] . '' . t('Filepath') . '' . $this->data['generalConfig']['logging_file'] . '
'; + } + + return $pageTitle . '
' . $generalTitle . $generalHtml . '
' + . '
' . $loggingTitle . $loggingHtml . '
'; } public function getReport() diff --git a/library/Icinga/Application/Installation/ResourceStep.php b/library/Icinga/Application/Installation/ResourceStep.php index 704203ff60..e22489e2b2 100644 --- a/library/Icinga/Application/Installation/ResourceStep.php +++ b/library/Icinga/Application/Installation/ResourceStep.php @@ -56,7 +56,84 @@ public function apply() public function getSummary() { - return ''; + if (isset($this->data['dbResourceConfig']) && isset($this->data['ldapResourceConfig'])) { + $pageTitle = '

' . t('Resources') . '

'; + } else { + $pageTitle = '

' . t('Resource') . '

'; + } + + if (isset($this->data['dbResourceConfig'])) { + $dbTitle = '

' . t('Database') . '

'; + $dbHtml = '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '
' . t('Resource Name') . '' . $this->data['dbResourceConfig']['name'] . '
' . t('Database Type') . '' . $this->data['dbResourceConfig']['db'] . '
' . t('Host') . '' . $this->data['dbResourceConfig']['host'] . '
' . t('Port') . '' . $this->data['dbResourceConfig']['port'] . '
' . t('Database Name') . '' . $this->data['dbResourceConfig']['dbname'] . '
' . t('Username') . '' . $this->data['dbResourceConfig']['username'] . '
' . t('Password') . '' . str_repeat('*', strlen($this->data['dbResourceConfig']['password'])) . '
'; + } + + if (isset($this->data['ldapResourceConfig'])) { + $ldapTitle = '

LDAP

'; + $ldapHtml = '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '
' . t('Resource Name') . '' . $this->data['ldapResourceConfig']['name'] . '
' . t('Host') . '' . $this->data['ldapResourceConfig']['hostname'] . '
' . t('Port') . '' . $this->data['ldapResourceConfig']['port'] . '
' . t('Root DN') . '' . $this->data['ldapResourceConfig']['root_dn'] . '
' . t('Bind DN') . '' . $this->data['ldapResourceConfig']['bind_dn'] . '
' . t('Bind Password') . '' . str_repeat('*', strlen($this->data['ldapResourceConfig']['bind_pw'])) . '
'; + } + + return $pageTitle . (isset($dbTitle) ? '
' . $dbTitle . $dbHtml . '
' : '') + . (isset($ldapTitle) ? '
' . $ldapTitle . $ldapHtml . '
' : ''); } public function getReport()