Package installation no longer uses the GET-parameter "action"
authorAlexander Ebert <ebert@woltlab.com>
Sun, 19 May 2013 16:47:00 +0000 (18:47 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 19 May 2013 16:47:00 +0000 (18:47 +0200)
Fixes #1262

wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl
wcfsetup/install/files/acp/templates/packageStartInstall.tpl
wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php
wcfsetup/install/files/lib/acp/page/PackageInstallationConfirmPage.class.php
wcfsetup/install/files/lib/system/package/PackageArchive.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index 3501f6ade52540ba3ae4599278052d5f07c359f8..9daa38e8e649925340dcb7183171a8a16b22a528 100644 (file)
@@ -7,7 +7,7 @@
                        'wcf.acp.package.installation.title': '{lang}wcf.acp.package.installation.title{/lang}',
                        'wcf.acp.package.uninstallation.title': '{lang}wcf.acp.package.uninstallation.title{/lang}'
                });
-               new WCF.ACP.Package.Installation({@$queueID}, undefined, true);
+               new WCF.ACP.Package.Installation({@$queue->queueID}, undefined, {if $queue->action == 'install'}true{else}false{/if});
        });
        //]]>
 </script>
 {/if}
 
 <div class="formSubmit">
-       <input type="button" onclick="document.location.href=fixURL('{link controller='Package'}action={@$action}&queueID={@$queueID}&step=cancel{/link}')" value="{lang}wcf.global.button.back{/lang}" accesskey="c" />
+       <input type="button" onclick="document.location.href=fixURL('{link controller='Package'}action={@$action}&queueID={@$queue->queueID}&step=cancel{/link}')" value="{lang}wcf.global.button.back{/lang}" accesskey="c" />
        {if $missingPackages == 0 && $excludingPackages|count == 0 && $excludedPackages|count == 0}
                <input type="button" id="submitButton" value="{lang}wcf.global.button.next{/lang}" class="default" accesskey="s" />
        {/if}
index b893de042042519a30c3fa850143ade8d32bdac2..3cad5620e9e61ba9a709d72aafb341c7b4c14c68 100644 (file)
@@ -1,4 +1,4 @@
-{if $packageID == 0}
+{if $package === null}
        {assign var='pageTitle' value='wcf.acp.package.startInstall'}
 {else}
        {assign var='pageTitle' value='wcf.acp.package.startUpdate'}
                        <div class="formSubmit">
                                <input type="submit" name="submitButton" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
                                <input type="hidden" name="action" value="{$action}" />
-                               {if $packageID != 0}<input type="hidden" name="id" value="{@$packageID}" />{/if}
                        </div>
                </form>
        </div>
index 19b3a7e6b30e6b13922b27a7e7b5cbbbd014887c..5a0f561f70f489934eb1f48436bc7006f8c8dbdb 100755 (executable)
@@ -5,6 +5,7 @@ use wcf\data\package\installation\queue\PackageInstallationQueueEditor;
 use wcf\data\package\Package;
 use wcf\form\AbstractForm;
 use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\SystemException;
 use wcf\system\exception\UserInputException;
 use wcf\system\package\PackageArchive;
@@ -18,7 +19,7 @@ use wcf\util\StringUtil;
  * Shows the package install and update form.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage acp.form
@@ -30,12 +31,6 @@ class PackageStartInstallForm extends AbstractForm {
         */
        public $activeMenuItem = 'wcf.acp.menu.link.package.install';
        
-       /**
-        * id of the updated package
-        * @var integer
-        */
-       public $packageID = 0;
-       
        /**
         * updated package object
         * @var wcf\system\package\Package
@@ -66,25 +61,6 @@ class PackageStartInstallForm extends AbstractForm {
         */
        public $queue = null;
        
-       /**
-        * @see wcf\form\IForm::readParameters()
-        */
-       public function readParameters() {
-               parent::readParameters();
-               
-               if (isset($_REQUEST['id'])) {
-                       $this->packageID = intval($_REQUEST['id']);
-                       if ($this->packageID != 0) {
-                               try {
-                                       $this->package = new Package($this->packageID);
-                               }
-                               catch (SystemException $e) {
-                                       throw new IllegalLinkException();
-                               }
-                       }
-               }
-       }
-       
        /**
         * @see wcf\form\IForm::readFormParameters()
         */
@@ -182,13 +158,30 @@ class PackageStartInstallForm extends AbstractForm {
                        throw new UserInputException($type, 'phpRequirements');
                }
                
+               // try to find existing package
+               $sql = "SELECT  *
+                       FROM    wcf".WCF_N."_package
+                       WHERE   package = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->archive->getPackageInfo('name')));
+               $row = $statement->fetchArray();
+               if ($row !== false) {
+                       $this->package = new Package(null, $row);
+               }
+               
                // check update or install support
                if ($this->package !== null) {
+                       WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage'));
+                       $this->activeMenuItem = 'wcf.acp.menu.link.package';
+                       
+                       $this->archive->setPackage($this->package);
                        if (!$this->archive->isValidUpdate()) {
                                throw new UserInputException($type, 'noValidUpdate');
                        }
                }
                else {
+                       WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
+                       
                        if (!$this->archive->isValidInstall()) {
                                throw new UserInputException($type, 'noValidInstall');
                        }
@@ -211,7 +204,7 @@ class PackageStartInstallForm extends AbstractForm {
                $processNo = PackageInstallationQueue::getNewProcessNo();
                
                // obey foreign key
-               $packageID = ($this->packageID) ? $this->packageID : null;
+               $packageID = ($this->package) ? $this->package->packageID : null;
                
                // insert queue
                $this->queue = PackageInstallationQueueEditor::create(array(
@@ -238,7 +231,6 @@ class PackageStartInstallForm extends AbstractForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign(array(
-                       'packageID' => $this->packageID,
                        'package' => $this->package
                ));
        }
@@ -247,10 +239,8 @@ class PackageStartInstallForm extends AbstractForm {
         * @see wcf\page\IPage::show()
         */
        public function show() {
-               if ($this->action == 'install') WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
-               else {
-                       WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage'));
-                       $this->activeMenuItem = 'wcf.acp.menu.link.package';
+               if (!WCF::getSession()->getPermission('admin.system.package.canInstallPackage') && !WCF::getSession()->getPermission('admin.system.package.canUpdatePackage')) {
+                       throw new PermissionDeniedException();
                }
                
                // check master password
index fb3740cbf5f847ee3b14dce9210cbb9063008db1..6dab03641dd0cf191074b1568fa1a7188cfd54cd 100644 (file)
@@ -11,7 +11,7 @@ use wcf\system\WCFACP;
  * Shows a confirmation page prior to start installing.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage acp.page
@@ -70,6 +70,13 @@ class PackageInstallationConfirmPage extends AbstractPage {
                if (!$this->queue->queueID || $this->queue->done) {
                        throw new IllegalLinkException();
                }
+               
+               if ($this->queue->action == 'install') {
+                       WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
+               }
+               else {
+                       WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage'));
+               }
        }
        
        /**
@@ -119,7 +126,7 @@ class PackageInstallationConfirmPage extends AbstractPage {
                        'missingPackages' => $this->missingPackages,
                        'excludingPackages' => $this->packageInstallationDispatcher->getArchive()->getConflictedExcludingPackages(),
                        'excludedPackages' => $this->packageInstallationDispatcher->getArchive()->getConflictedExcludedPackages(),
-                       'queueID' => $this->queue->queueID
+                       'queue' => $this->queue
                ));
        }
        
@@ -130,13 +137,6 @@ class PackageInstallationConfirmPage extends AbstractPage {
                // check master password
                WCFACP::checkMasterPassword();
                
-               if ($this->action == 'install') {
-                       WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
-               }
-               else {
-                       WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage'));
-               }
-               
                parent::show();
        }
 }
index 475a1ac2fb6c3786bb824c2a60f6a6e3606ccbef..c0c674f59a24b58eb2a9ade62393d822100a7a36 100644 (file)
@@ -101,6 +101,15 @@ class PackageArchive {
                $this->package = $package;
        }
        
+       /**
+        * Sets associated package object.
+        * 
+        * @param       wcf\data\package\Package        $package
+        */
+       public function setPackage(Package $package) {
+               $this->package = $package;
+       }
+       
        /**
         * Returns the name of the package archive.
         * 
index 4bcadbeb74c672085c40aa9a5020d921300de81c..5054260911c780adc6553096a41ad06b206110b1 100644 (file)
@@ -720,7 +720,7 @@ class PackageInstallationDispatcher {
                        exit;
                }
                else {
-                       $url = LinkHandler::getInstance()->getLink('PackageInstallationConfirm', array(), 'action='.$packageInstallation['action'].'&queueID='.$packageInstallation['queueID']);
+                       $url = LinkHandler::getInstance()->getLink('PackageInstallationConfirm', array(), 'queueID='.$packageInstallation['queueID']);
                        HeaderUtil::redirect($url);
                        exit;
                }