From: Alexander Ebert Date: Sun, 19 May 2013 16:47:00 +0000 (+0200) Subject: Package installation no longer uses the GET-parameter "action" X-Git-Tag: 2.0.0_Beta_1~144^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ec45d5e8f5843ca36480343256bc84db07898239;p=GitHub%2FWoltLab%2FWCF.git Package installation no longer uses the GET-parameter "action" Fixes #1262 --- diff --git a/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl b/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl index 3501f6ade5..9daa38e8e6 100644 --- a/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl +++ b/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl @@ -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}); }); //]]> @@ -107,7 +107,7 @@ {/if}
- + {if $missingPackages == 0 && $excludingPackages|count == 0 && $excludedPackages|count == 0} {/if} diff --git a/wcfsetup/install/files/acp/templates/packageStartInstall.tpl b/wcfsetup/install/files/acp/templates/packageStartInstall.tpl index b893de0420..3cad5620e9 100644 --- a/wcfsetup/install/files/acp/templates/packageStartInstall.tpl +++ b/wcfsetup/install/files/acp/templates/packageStartInstall.tpl @@ -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'} @@ -125,7 +125,6 @@
- {if $packageID != 0}{/if}
diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index 19b3a7e6b3..5a0f561f70 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -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 * @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 diff --git a/wcfsetup/install/files/lib/acp/page/PackageInstallationConfirmPage.class.php b/wcfsetup/install/files/lib/acp/page/PackageInstallationConfirmPage.class.php index fb3740cbf5..6dab03641d 100644 --- a/wcfsetup/install/files/lib/acp/page/PackageInstallationConfirmPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PackageInstallationConfirmPage.class.php @@ -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 * @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(); } } diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 475a1ac2fb..c0c674f59a 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -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. * diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 4bcadbeb74..5054260911 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -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; }