aboutsummaryrefslogtreecommitdiffstats
path: root/core/Controller/SetupController.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Controller/SetupController.php')
-rw-r--r--core/Controller/SetupController.php97
1 files changed, 50 insertions, 47 deletions
diff --git a/core/Controller/SetupController.php b/core/Controller/SetupController.php
index cdab39edf84..f89506680ad 100644
--- a/core/Controller/SetupController.php
+++ b/core/Controller/SetupController.php
@@ -1,49 +1,32 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Damjan Georgievski <gdamjan@gmail.com>
- * @author ideaship <ideaship@users.noreply.github.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Controller;
+use OC\IntegrityCheck\Checker;
use OC\Setup;
-use OCP\ILogger;
+use OCP\IInitialStateService;
+use OCP\IURLGenerator;
+use OCP\Server;
+use OCP\Template\ITemplateManager;
+use OCP\Util;
+use Psr\Log\LoggerInterface;
class SetupController {
- protected Setup $setupHelper;
private string $autoConfigFile;
- /**
- * @param Setup $setupHelper
- */
- public function __construct(Setup $setupHelper) {
- $this->autoConfigFile = \OC::$configDir.'autoconfig.php';
- $this->setupHelper = $setupHelper;
+ public function __construct(
+ protected Setup $setupHelper,
+ protected LoggerInterface $logger,
+ protected ITemplateManager $templateManager,
+ protected IInitialStateService $initialStateService,
+ protected IURLGenerator $urlGenerator,
+ ) {
+ $this->autoConfigFile = \OC::$configDir . 'autoconfig.php';
}
public function run(array $post): void {
@@ -81,11 +64,11 @@ class SetupController {
}
}
- private function displaySetupForbidden() {
- \OC_Template::printGuestPage('', 'installation_forbidden');
+ private function displaySetupForbidden(): void {
+ $this->templateManager->printGuestPage('', 'installation_forbidden');
}
- public function display($post): void {
+ public function display(array $post): void {
$defaults = [
'adminlogin' => '',
'adminpass' => '',
@@ -95,31 +78,53 @@ class SetupController {
'dbtablespace' => '',
'dbhost' => 'localhost',
'dbtype' => '',
+ 'hasAutoconfig' => false,
+ 'serverRoot' => \OC::$SERVERROOT,
];
$parameters = array_merge($defaults, $post);
- \OC_Template::printGuestPage('', 'installation', $parameters);
+ Util::addStyle('server', null);
+
+ // include common nextcloud webpack bundle
+ Util::addScript('core', 'common');
+ Util::addScript('core', 'main');
+ Util::addScript('core', 'install');
+ Util::addTranslations('core');
+
+ $this->initialStateService->provideInitialState('core', 'config', $parameters);
+ $this->initialStateService->provideInitialState('core', 'data', false);
+ $this->initialStateService->provideInitialState('core', 'links', [
+ 'adminInstall' => $this->urlGenerator->linkToDocs('admin-install'),
+ 'adminSourceInstall' => $this->urlGenerator->linkToDocs('admin-source_install'),
+ 'adminDBConfiguration' => $this->urlGenerator->linkToDocs('admin-db-configuration'),
+ ]);
+
+ $this->templateManager->printGuestPage('', 'installation');
}
- private function finishSetup() {
+ private function finishSetup(): void {
if (file_exists($this->autoConfigFile)) {
unlink($this->autoConfigFile);
}
- \OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
+ Server::get(Checker::class)->runInstanceVerification();
if ($this->setupHelper->shouldRemoveCanInstallFile()) {
- \OC_Template::printGuestPage('', 'installation_incomplete');
+ $this->templateManager->printGuestPage('', 'installation_incomplete');
}
- header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
+ header('Location: ' . Server::get(IURLGenerator::class)->getAbsoluteURL('index.php/core/apps/recommended'));
exit();
}
+ /**
+ * @psalm-taint-escape file we trust file path given in POST for setup
+ */
public function loadAutoConfig(array $post): array {
if (file_exists($this->autoConfigFile)) {
- \OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO);
+ $this->logger->info('Autoconfig file found, setting up Nextcloud…');
$AUTOCONFIG = [];
include $this->autoConfigFile;
+ $post['hasAutoconfig'] = count($AUTOCONFIG) > 0;
$post = array_merge($post, $AUTOCONFIG);
}
@@ -130,8 +135,6 @@ class SetupController {
if ($dbIsSet and $directoryIsSet and $adminAccountIsSet) {
$post['install'] = 'true';
}
- $post['dbIsSet'] = $dbIsSet;
- $post['directoryIsSet'] = $directoryIsSet;
return $post;
}