[BUGFIX] Always use uc_default after first install
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / DefaultConfiguration.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Step;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Install\Service\EnableFileService;
18
19 /**
20 * Set production defaults
21 */
22 class DefaultConfiguration extends AbstractStepAction {
23
24 /**
25 * Set defaults of auto configuration, mark installation as completed
26 *
27 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
28 */
29 public function execute() {
30 /** @var \TYPO3\CMS\Install\Configuration\FeatureManager $featureManager */
31 $featureManager = $this->objectManager->get('TYPO3\\CMS\\Install\\Configuration\\FeatureManager');
32 // Get best matching configuration presets
33 $configurationValues = $featureManager->getBestMatchingConfigurationForAllFeatures();
34
35 // let the admin user redirect to the distributions page on first login
36 if (isset($this->postValues['values']['loaddistributions'])) {
37
38 // update the admin backend user to show the distribution management on login
39 $adminUserFirstLogin = array(
40 'startModuleOnFirstLogin' => 'tools_ExtensionmanagerExtensionmanager->tx_extensionmanager_tools_extensionmanagerextensionmanager%5Baction%5D=distributions&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bcontroller%5D=List',
41 'ucSetByInstallTool' => '1',
42 );
43 $this->getDatabaseConnection()->exec_UPDATEquery(
44 'be_users',
45 'admin=1',
46 array('uc' => serialize($adminUserFirstLogin))
47 );
48 }
49
50 // Setting SYS/isInitialInstallationInProgress to FALSE marks this instance installation as complete
51 $configurationValues['SYS/isInitialInstallationInProgress'] = FALSE;
52
53 /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
54 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
55 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
56
57 /** @var \TYPO3\CMS\Install\Service\SessionService $session */
58 $session = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SessionService');
59 $session->destroySession();
60
61 /** @var $formProtection \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection */
62 $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get(
63 'TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection'
64 );
65 $formProtection->clean();
66
67 if (!EnableFileService::isInstallToolEnableFilePermanent()) {
68 EnableFileService::removeInstallToolEnableFile();
69 }
70
71 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('../../../index.php', \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
72 }
73
74 /**
75 * Step needs to be executed if 'isInitialInstallationInProgress' is set to TRUE in LocalConfiguration
76 *
77 * @return boolean
78 */
79 public function needsExecution() {
80 $result = FALSE;
81 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'])
82 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'] === TRUE
83 ) {
84 $result = TRUE;
85 }
86 return $result;
87 }
88
89 /**
90 * Executes the step
91 *
92 * @return string Rendered content
93 */
94 protected function executeAction() {
95 $this->assignSteps();
96 return $this->view->render();
97 }
98 }