[TASK] Ask confirmation to install "adminpanel" extension 10/57310/4
authorMathias Brodala <mbrodala@pagemachine.de>
Fri, 22 Jun 2018 19:50:57 +0000 (21:50 +0200)
committerMathias Brodala <mbrodala@pagemachine.de>
Fri, 22 Jun 2018 21:34:04 +0000 (23:34 +0200)
Resolves: #84789
Releases: master
Change-Id: I5b59519eb3497c7c459efe1f238c91f4fe7e9e19
Reviewed-on: https://review.typo3.org/57310
Reviewed-by: Aljoscha Weber <aweber@w-commerce.de>
Tested-by: Aljoscha Weber <aweber@w-commerce.de>
Reviewed-by: Jonas Götze <jonnsn@gmail.com>
Tested-by: Jonas Götze <jonnsn@gmail.com>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
typo3/sysext/install/Classes/Updates/AdminPanelInstall.php
typo3/sysext/install/ext_localconf.php

index 861a8d7..6c7fc89 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\Updates;
  */
 
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Installs EXT:adminpanel
@@ -33,6 +34,9 @@ class AdminPanelInstall extends AbstractDownloadExtensionUpdate
      */
     protected $extensionKey = 'adminpanel';
 
+    /**
+     * @var array
+     */
     protected $extensionDetails = [
         'adminpanel' => [
             'title' => 'TYPO3 Admin Panel',
@@ -64,6 +68,34 @@ class AdminPanelInstall extends AbstractDownloadExtensionUpdate
     }
 
     /**
+     * Second step: Ask user to install the extension
+     *
+     * @param string $inputPrefix input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
+     * @return string HTML output
+     */
+    public function getUserInput($inputPrefix)
+    {
+        return '
+            <div class="panel panel-danger">
+                <div class="panel-heading">Are you really sure?</div>
+                <div class="panel-body">
+                    <p>You should install EXT:adminpanel only if you really need it.</p>
+                    <p>This update wizard cannot check if the extension was installed before the update.</p>
+                    <p>Are you really sure, you want to install EXT:adminpanel?</p>
+                    <div class="btn-group clearfix" data-toggle="buttons">
+                        <label class="btn btn-default active">
+                            <input type="radio" name="' . $inputPrefix . '[install]" value="0" checked="checked" /> no, don\'t install
+                        </label>
+                        <label class="btn btn-default">
+                            <input type="radio" name="' . $inputPrefix . '[install]" value="1" /> yes, please install
+                        </label>
+                    </div>
+                </div>
+            </div>
+        ';
+    }
+
+    /**
      * Performs the update
      *
      * @param array $databaseQueries Queries done in this update
@@ -72,9 +104,23 @@ class AdminPanelInstall extends AbstractDownloadExtensionUpdate
      */
     public function performUpdate(array &$databaseQueries, &$customMessage): bool
     {
-        $updateSuccessful = $this->installExtension($this->extensionKey, $customMessage);
-        if ($updateSuccessful) {
+        $requestParams = GeneralUtility::_GP('install');
+        if (!isset($requestParams['values']['adminpanelExtension']['install'])) {
+            return false;
+        }
+        $install = (int)$requestParams['values']['adminpanelExtension']['install'];
+
+        if ($install === 1) {
+            // user decided to install extension, install and mark wizard as done
+            $updateSuccessful = $this->installExtension($this->extensionKey, $customMessage);
+            if ($updateSuccessful) {
+                $this->markWizardAsDone();
+                return true;
+            }
+        } else {
+            // user decided to not install extension, mark wizard as done
             $this->markWizardAsDone();
+            return true;
         }
         return $updateSuccessful;
     }
index a8eb1bf..f99670e 100644 (file)
@@ -62,7 +62,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['backendLayou
     = \TYPO3\CMS\Install\Updates\BackendLayoutIconUpdateWizard::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['redirects']
     = \TYPO3\CMS\Install\Updates\RedirectsExtensionUpdate::class;
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['adminPanelInstall']
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['adminpanelExtension']
     = \TYPO3\CMS\Install\Updates\AdminPanelInstall::class;
 
 $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);