Redirecting to application within WCFSetup
authorAlexander Ebert <ebert@woltlab.com>
Wed, 1 Feb 2012 13:18:11 +0000 (14:18 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 1 Feb 2012 13:18:11 +0000 (14:18 +0100)
Fixes #390

wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php

index 84404a6cbadc04cff834f89ace5406e20e1ca798..ec09d6b73c7e752d979874bd3bc6259e122097a0 100644 (file)
@@ -361,7 +361,7 @@ WCF.ACP.Package.Installation.prototype = {
                                $('#packageInstallationInnerContent').append('<div class="formSubmit"><input type="button" id="' + $id + '" value="' + WCF.Language.get('wcf.global.button.next') + '" class="default" /></div>');
                                
                                $('#' + $id).click(function() {
-                                       window.location.href = "index.php/PackageList/" + SID_ARG_1ST;
+                                       window.location.href = data.redirectLocation;
                                });
                                
                                $('#packageInstallationInnerContentContainer').show();
index d253c5488284567953faf4527a09877d8953478b..db28bd2b06148f4dc455e7a77e2f1871ec1219d1 100755 (executable)
@@ -86,10 +86,39 @@ class InstallPackageAction extends AbstractDialogAction {
                                // perform final actions
                                $this->installation->completeSetup();
                                
+                               // redirect to application if not already within one
+                               if (PACKAGE_ID == 1) {
+                                       // select first installed application
+                                       $sql = "SELECT          packageID
+                                               FROM            wcf".WCF_N."_package
+                                               WHERE           packageID <> 1
+                                                               AND isApplication = 1
+                                               ORDER BY        installDate ASC";
+                                       $statement = WCF::getDB()->prepareStatement($sql, 1);
+                                       $statement->execute();
+                                       $row = $statement->fetchArray();
+                                       $packageID = ($row === false) ? 1 : $row['packageID'];
+                               }
+                               else {
+                                       $packageID = PACKAGE_ID;
+                               }
+                                       
+                               // get domain path
+                               $sql = "SELECT  domainName, domainPath
+                                       FROM    wcf".WCF_N."_application
+                                       WHERE   packageID = ?";
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute(array($packageID));
+                               $row = $statement->fetchArray();
+                               
+                               // build redirect location
+                               $location = $row['domainName'] . $row['domainPath'] . 'index.php/PackageList/' . SID_ARG_1ST;
+                               
                                // show success
                                $this->data = array(
                                        'currentAction' => $this->getCurrentAction(null),
                                        'progress' => 100,
+                                       'redirectLocation' => $location,
                                        'step' => 'success'
                                );
                                return;