}
});
+/**
+ * Handles canceling the package installation at the package installation
+ * confirm page.
+ */
+WCF.ACP.Package.Installation.Cancel = Class.extend({
+ /**
+ * Creates a new instance of WCF.ACP.Package.Installation.Cancel.
+ *
+ * @param integer queueID
+ */
+ init: function(queueID) {
+ $('#backButton').click(function() {
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: 'cancelInstallation',
+ className: 'wcf\\data\\package\\installation\\queue\\PackageInstallationQueueAction',
+ objectIDs: [ queueID ]
+ },
+ success: function(data) {
+ window.location = data.returnValues.url;
+ }
+ });
+ });
+ }
+});
+
/**
* Provides the package uninstallation.
*
'wcf.acp.package.uninstallation.title': '{lang}wcf.acp.package.uninstallation.title{/lang}',
'wcf.acp.package.update.title': '{lang}wcf.acp.package.update.title{/lang}'
});
+
new WCF.ACP.Package.Installation({@$queue->queueID}, undefined, {if $queue->action == 'install'}true, false{else}false, true{/if});
+
+ new WCF.ACP.Package.Installation.Cancel({@$queue->queueID});
});
//]]>
</script>
{/if}
<div class="formSubmit">
- {* @todo: <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" />*}
+ <input type="button" id="backButton" value="{lang}wcf.global.button.back{/lang}" accesskey="c" />
{if $missingPackages == 0 && $excludingPackages|count == 0 && $excludedPackages|count == 0}
<input type="button" class="buttonPrimary" id="submitButton" value="{lang}wcf.global.button.next{/lang}" class="default" accesskey="s" />
{/if}
namespace wcf\data\package\installation\queue;
use wcf\data\package\Package;
use wcf\data\AbstractDatabaseObjectAction;
+use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
+use wcf\system\request\LinkHandler;
use wcf\system\WCF;
/**
*/
class PackageInstallationQueueAction extends AbstractDatabaseObjectAction {
/**
- * package the prepared queue belongs to
- * @var wcf\data\package\Package
+ * @see wcf\data\AbstractDatabaseObjectAction::$className
*/
- protected $package = null;
+ protected $className = 'wcf\data\package\installation\queue\PackageInstallationQueueEditor';
/**
- * @see wcf\data\AbstractDatabaseObjectAction::$className
+ * queue of the canceled installation
+ * @var wcf\data\package\installation\queue\PackageInstallationQueueEditor
*/
- protected $className = 'wcf\data\package\installation\queue\PackageInstallationQueueEditor';
+ protected $queue = null;
+
+ /**
+ * package the prepared queue belongs to
+ * @var wcf\data\package\Package
+ */
+ protected $package = null;
/**
* Validates the 'prepareQueue' action:
'queueID' => $queue->queueID
);
}
+
+ /**
+ * Validates the 'cancelInstallation' action.
+ */
+ public function validateCancelInstallation() {
+ // check permissions
+ WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
+
+ // validate queue
+ $this->queue = $this->getSingleObject();
+ if ($this->queue->parentQueueID || $this->queue->action != 'install' || $this->queue->done) {
+ throw new UserInputException('objectIDs');
+ }
+
+ // todo: do confirmInstallation and packageType need validation?
+ // see https://github.com/WoltLab/WCF/issues/1329
+ // see https://github.com/WoltLab/WCF/issues/1330
+
+ if ($this->queue->userID != WCF::getUser()->userID) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * Cancels a certain installation.
+ */
+ public function cancelInstallation() {
+ @unlink($this->queue->archive);
+
+ $this->queue->delete();
+
+ return array(
+ 'url' => LinkHandler::getInstance()->getLink('PackageList')
+ );
+ }
}