'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}
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;
* 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
*/
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
*/
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()
*/
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');
}
$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(
parent::assignVariables();
WCF::getTPL()->assign(array(
- 'packageID' => $this->packageID,
'package' => $this->package
));
}
* @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
* 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
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'));
+ }
}
/**
'missingPackages' => $this->missingPackages,
'excludingPackages' => $this->packageInstallationDispatcher->getArchive()->getConflictedExcludingPackages(),
'excludedPackages' => $this->packageInstallationDispatcher->getArchive()->getConflictedExcludedPackages(),
- 'queueID' => $this->queue->queueID
+ 'queue' => $this->queue
));
}
// 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();
}
}