[!!!][TASK] Rewrite install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / BackendModuleController.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Backend module controller
32 *
33 * Embeds in backend an only shows the 'enable install tool button' or redirects
34 * to step installer if install tool is enabled.
35 *
36 * This is a classic extbase module that does not interfere with the other code
37 * within the install tool.
38 */
39 class BackendModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
40
41 /**
42 * Index action shows install tool / step installer or redirect to action to enable install tool
43 *
44 * @return void
45 */
46 public function indexAction() {
47 /** @var $enableFileService \TYPO3\CMS\Install\Service\EnableFileService */
48 $enableFileService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
49 if ($enableFileService->checkInstallToolEnableFile()) {
50 // Install Tool is already enabled
51 $enableFileService->extendInstallToolEnableFileLifetime();
52 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('sysext/install/Start/Install.php?install[context]=backend');
53 } else {
54 $this->redirect('showEnableInstallToolButton');
55 }
56 }
57
58 /**
59 * Show enable install tool
60 *
61 * @return void
62 */
63 public function showEnableInstallToolButtonAction() {
64 $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
65 $token = $formProtection->generateToken('installTool');
66 $this->view->assign('installToolEnableToken', $token);
67 }
68
69 /**
70 * Enable the install tool
71 *
72 * @throws \RuntimeException
73 */
74 public function enableInstallToolAction() {
75 $token = $GLOBALS['_POST']['tx_install_tools_installinstall']['installToolEnableToken'];
76 if (\TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->validateToken($token, 'installTool')) {
77 $installToolService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
78 $installToolService->createInstallToolEnableFile();
79 $this->redirect('index');
80 } else {
81 throw new \RuntimeException(
82 'Given form token was not valid',
83 1369161225
84 );
85 }
86 }
87 }
88
89 ?>