[TASK] Redirect to distributions after first login 66/27866/5
authorBenjamin Mack <benni@typo3.org>
Wed, 26 Feb 2014 12:24:55 +0000 (13:24 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 6 Mar 2014 13:28:59 +0000 (14:28 +0100)
For the users to select a distribution, the installation should
redirect directly to the extension manager, after the first
login of the admin, who set up the site.

Then, the list of TER extensions is loaded initially and all
distributions are shown.

For this to happen, the install tool needs to add another option
that sets a UC flag in the just created admin user.
This UC flag is evaluated when the start module is to be shown.

Also, it adds some more logic when redirecting to the start module
to allow to directly jump to a modfunc/action.

Additionally, the distribution action should initially load all
extensions from TER on first hit.

Releases: 6.2
Resolves: #56321
Change-Id: I1e86b5804011e84f7936514e4b88c4a257905e56
Reviewed-on: https://review.typo3.org/27866
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/backend/Classes/Controller/BackendController.php
typo3/sysext/extensionmanager/Classes/Controller/ListController.php
typo3/sysext/install/Classes/Controller/Action/Step/DefaultConfiguration.php
typo3/sysext/install/Resources/Private/Templates/Action/Step/DefaultConfiguration.html

index 235e383..cda6977 100644 (file)
@@ -597,20 +597,37 @@ class BackendController {
        }
 
        /**
-        * Sets the startup module from either GETvars module and mpdParams or user configuration.
+        * Sets the startup module from either GETvars module and modParams or user configuration.
         *
-        * @return void
+        * @return string the JavaScript code for the startup module
         */
        protected function setStartupModule() {
                $startModule = preg_replace('/[^[:alnum:]_]/', '', GeneralUtility::_GET('module'));
                if (!$startModule) {
-                       if ($GLOBALS['BE_USER']->uc['startModule']) {
+                       // start module on first login, will be removed once used the first time
+                       if (isset($GLOBALS['BE_USER']->uc['startModuleOnFirstLogin'])) {
+                               $startModule = $GLOBALS['BE_USER']->uc['startModuleOnFirstLogin'];
+                               unset($GLOBALS['BE_USER']->uc['startModuleOnFirstLogin']);
+                               $GLOBALS['BE_USER']->writeUC();
+                       } elseif ($GLOBALS['BE_USER']->uc['startModule']) {
                                $startModule = $GLOBALS['BE_USER']->uc['startModule'];
                        } elseif ($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
                                $startModule = 'user_task';
                        }
+
+                       // check if the start module has additional parameters, so a redirect to a specific
+                       // action is possible
+                       if (strpos($startModule, '->') !== FALSE) {
+                               list($startModule, $startModuleParameters) = explode('->', $startModule, 2);
+                       }
                }
+
                $moduleParameters = GeneralUtility::_GET('modParams');
+               // if no GET parameters are set, check if there are parameters given from the UC
+               if (!$moduleParameters && $startModuleParameters) {
+                       $moduleParameters = $startModuleParameters;
+               }
+
                if ($startModule) {
                        return '
                                        // start in module:
index 0160f9f..5996b50 100644 (file)
@@ -95,6 +95,15 @@ class ListController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCont
         * @return void
         */
        public function distributionsAction() {
+               // check if a TER update has been done at all, if not, fetch it directly
+               /** @var $repositoryHelper \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper */
+               $repositoryHelper = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper');
+               // repository needs an update, but not because of the extension hash has changed
+               if ($repositoryHelper->isExtListUpdateNecessary() > 0 && ($repositoryHelper->isExtListUpdateNecessary() & $repositoryHelper::PROBLEM_EXTENSION_HASH_CHANGED) === 0) {
+                       $repositoryHelper->fetchExtListFile();
+                       $repositoryHelper->updateExtList();
+               }
+
                $distributions = $this->extensionRepository->findAllDistributions();
                $this->view->assign('distributions', $distributions);
        }
index 5e48d25..6528e3e 100644 (file)
@@ -40,6 +40,18 @@ class DefaultConfiguration extends AbstractStepAction {
                // Get best matching configuration presets
                $configurationValues = $featureManager->getBestMatchingConfigurationForAllFeatures();
 
+               // let the admin user redirect to the distributions page on first login
+               if (isset($this->postValues['values']['loaddistributions'])) {
+
+                       // update the admin backend user to show the distribution management on login
+                       $adminUserFirstLogin = array('startModuleOnFirstLogin' => 'tools_ExtensionmanagerExtensionmanager->tx_extensionmanager_tools_extensionmanagerextensionmanager%5Baction%5D=distributions&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bcontroller%5D=List');
+                       $this->getDatabase()->exec_UPDATEquery(
+                                       'be_users',
+                                       'admin=1',
+                                       array('uc' => serialize($adminUserFirstLogin))
+                       );
+               }
+
                // Setting SYS/isInitialInstallationInProgress to FALSE marks this instance installation as complete
                $configurationValues['SYS/isInitialInstallationInProgress'] = FALSE;
 
index bdab285..7febdff 100644 (file)
@@ -3,7 +3,7 @@
 <f:layout name="Step" />
 
 <f:section name="Content">
-       <h3>Auto configuration and login</h3>
+       <h3>Auto configuration, distributions and login</h3>
 
        <p>
                Installation done! This last step will set some configuration values based on your
                with the user you just created.
        </p>
 
+       <h4>Want a pre-configured site?</h4>
+       <p>
+               You now have an empty installation. If you want a pre-configured site, there are
+               distributions on the web, which can be installed via the Extension Mananger.
+               If you check the option below, you will be redirected to the distributions
+               center, where a list of distributions is fetched. <strong>Please note:
+               This may take some time after the login.</strong>
+       </p>
+
        <form method="post">
                <f:render partial="Action/Common/HiddenFormFields" arguments="{_all}" />
                <input type="hidden" value="execute" name="install[set]" />
-
+               <fieldset class="t3-install-form-label-width-21 t3-install-form-label-after">
+                       <ol>
+                               <li>
+                                       <input type="checkbox" id="load-distributions" name="install[values][loaddistributions]" value="1" checked="checked" />
+                                       <label for="load-distributions">Yes, download the list of distributions.</label>
+                               </li>
+                       </ol>
+               </fieldset>
+               <hr />
                <button type="submit">
                        Continue
                </button>