2 declare(strict_types = 1);
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
20 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
32 use TYPO3\CMS\Core\Package\PackageManager;
52 public function cardsAction(ServerRequestInterface $request): ResponseInterface
57 'html' => $view->render(),
71 $view->assignMultiple([
72 'changeInstallToolPasswordToken' => $formProtection->generateToken(
'installTool',
'changeInstallToolPassword'),
76 'html' => $view->render(),
88 $password = $request->getParsedBody()[
'install'][
'password'] ??
'';
89 $passwordCheck = $request->getParsedBody()[
'install'][
'passwordCheck'];
92 if ($password !== $passwordCheck) {
94 'Install tool password not changed. Given passwords do not match.',
98 } elseif (strlen($password) < 8) {
100 'Install tool password not changed. Given password must be at least eight characters long.',
105 $hashInstance = GeneralUtility::makeInstance(PasswordHashFactory::class)->getDefaultHashInstance(
'BE');
106 $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
107 $configurationManager->setLocalConfigurationValueByPath(
108 'BE/installToolPassword',
109 $hashInstance->getHashedPassword($password)
111 $messageQueue->enqueue(
new FlashMessage(
'Install tool password changed'));
115 'status' => $messageQueue,
129 $view->assignMultiple([
130 'systemMaintainerWriteToken' => $formProtection->generateToken(
'installTool',
'systemMaintainerWrite'),
131 'systemMaintainerIsDevelopmentContext' => GeneralUtility::getApplicationContext()->isDevelopment(),
134 $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
137 $queryBuilder = $connectionPool->getQueryBuilderForTable(
'be_users');
138 $queryBuilder->getRestrictions()->removeAll();
139 $users = $queryBuilder
140 ->select(
'uid',
'username',
'disable',
'starttime',
'endtime')
143 $queryBuilder->expr()->andX(
144 $queryBuilder->expr()->eq(
'deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
145 $queryBuilder->expr()->eq(
'admin', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)),
146 $queryBuilder->expr()->neq(
'username', $queryBuilder->createNamedParameter(
'_cli_', \PDO::PARAM_STR))
153 $systemMaintainerList =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemMaintainers'] ?? [];
154 $systemMaintainerList = array_map(
'intval', $systemMaintainerList);
155 $currentTime = time();
156 foreach ($users as &$user) {
157 $user[
'disable'] = $user[
'disable'] ||
158 ((int)$user[
'starttime'] !== 0 && $user[
'starttime'] > $currentTime) ||
159 ((int)$user[
'endtime'] !== 0 && $user[
'endtime'] < $currentTime);
160 $user[
'isSystemMaintainer'] = in_array((
int)$user[
'uid'], $systemMaintainerList,
true);
166 'html' => $view->render(),
180 $users = $request->getParsedBody()[
'install'][
'users'] ?? [];
181 if (is_array($users)) {
182 foreach ($users as $uid) {
184 $newUserList[] = (int)$uid;
189 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'be_users');
190 $queryBuilder->getRestrictions()->removeAll();
192 $validatedUserList = $queryBuilder
196 $queryBuilder->expr()->andX(
197 $queryBuilder->expr()->eq(
'deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
198 $queryBuilder->expr()->eq(
'admin', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)),
199 $queryBuilder->expr()->in(
'uid', $queryBuilder->createNamedParameter($newUserList, Connection::PARAM_INT_ARRAY))
201 )->execute()->fetchAll();
203 $validatedUserList = array_column($validatedUserList,
'uid');
204 $validatedUserList = array_map(
'intval', $validatedUserList);
206 $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
207 $configurationManager->setLocalConfigurationValuesByPathValuePairs(
208 [
'SYS/systemMaintainers' => $validatedUserList]
212 if (empty($validatedUserList)) {
215 'Set system maintainer list to an empty array',
220 implode(
', ', $validatedUserList),
221 'New system maintainer uid list',
227 'status' => $messages
242 $view->assignMultiple([
243 'localConfigurationWriteToken' => $formProtection->generateToken(
'installTool',
'localConfigurationWrite'),
244 'localConfigurationData' => $localConfigurationValueService->getCurrentConfigurationData(),
248 'html' => $view->render(),
261 $settings = $request->getParsedBody()[
'install'][
'configurationValues'];
262 if (!is_array($settings) || empty($settings)) {
263 throw new \RuntimeException(
264 'Expected value array not found',
269 $messageQueue = $localConfigurationValueService->updateLocalConfigurationValues($settings);
270 if (empty($messageQueue)) {
279 'status' => $messageQueue,
292 $presetFeatures = GeneralUtility::makeInstance(FeatureManager::class);
293 $presetFeatures = $presetFeatures->getInitializedFeatures($request->getParsedBody()[
'install'][
'values'] ?? []);
295 $view->assignMultiple([
296 'presetsActivateToken' => $formProtection->generateToken(
'installTool',
'presetsActivate'),
298 'presetsGetContentToken' => $formProtection->generateToken(
'installTool',
'presetsGetContent'),
299 'presetFeatures' => $presetFeatures,
303 'html' => $view->render(),
316 $configurationManager =
new ConfigurationManager();
318 $configurationValues = $featureManager->getConfigurationForSelectedFeaturePresets($request->getParsedBody()[
'install'][
'values'] ?? []);
319 if (!empty($configurationValues)) {
320 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
322 foreach ($configurationValues as $configurationKey => $configurationValue) {
323 $messageBody[] =
'\'' . $configurationKey .
'\' => \
'' . $configurationValue .
'\'';
326 implode(
', ', $messageBody),
327 'Configuration written'
332 'No configuration change selected',
338 'status' => $messages,
353 $extensionsWithConfigurations = [];
354 $activePackages = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
355 foreach ($activePackages as $extensionKey => $activePackage) {
356 if (@file_exists($activePackage->getPackagePath() .
'ext_conf_template.txt')) {
357 $extensionsWithConfigurations[$extensionKey] = [
358 'packageInfo' => $activePackage,
359 'configuration' => $extensionConfigurationService->getConfigurationPreparedForView($extensionKey),
363 ksort($extensionsWithConfigurations);
366 $view->assignMultiple([
367 'extensionsWithConfigurations' => $extensionsWithConfigurations,
368 'extensionConfigurationWriteToken' => $formProtection->generateToken(
'installTool',
'extensionConfigurationWrite'),
372 'html' => $view->render(),
384 $extensionKey = $request->getParsedBody()[
'install'][
'extensionKey'];
385 $configuration = $request->getParsedBody()[
'install'][
'extensionConfiguration'];
386 $nestedConfiguration = [];
387 foreach ($configuration as $configKey => $value) {
393 'Successfully saved configuration for extension "' . $extensionKey .
'"',
400 'status' => $messages,
412 $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
413 $configurationDescription = GeneralUtility::makeInstance(YamlFileLoader::class)
414 ->load($configurationManager->getDefaultConfigurationDescriptionFileLocation());
415 $allFeatures =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'features'] ?? [];
417 foreach ($allFeatures as $featureName => $featureValue) {
421 if (isset($configurationDescription[
'SYS'][
'items'][
'features'][
'items'][$featureName][
'description'])) {
422 $default = $configurationManager->getDefaultConfigurationValueByPath(
'SYS/features/' . $featureName);
424 'name' => $featureName,
425 'description' => $configurationDescription[
'SYS'][
'items'][
'features'][
'items'][$featureName][
'description'],
426 'default' => $default,
427 'value' => $featureValue,
433 $view->assignMultiple([
434 'features' => $features,
435 'featuresSaveToken' => $formProtection->generateToken(
'installTool',
'featuresSave'),
439 'html' => $view->render(),
451 $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
452 $enabledFeaturesFromPost = $request->getParsedBody()[
'install'][
'values'] ?? [];
453 $allFeatures = array_keys(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'features'] ?? []);
454 $configurationDescription = GeneralUtility::makeInstance(YamlFileLoader::class)
455 ->load($configurationManager->getDefaultConfigurationDescriptionFileLocation());
456 foreach ($allFeatures as $featureName) {
460 if (isset($configurationDescription[
'SYS'][
'items'][
'features'][
'items'][$featureName][
'description'])) {
461 if (isset($enabledFeaturesFromPost[$featureName])) {
462 $configurationManager->enableFeature($featureName);
464 $configurationManager->disableFeature($featureName);
470 'Successfully updated feature toggles',
477 'status' => $messages,