_prepareQueue: function(event) {
var $element = $(event.target);
+ if ($element.data('isRequired')) {
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: 'getConfirmMessage',
+ className: 'wcf\\data\\package\\PackageAction',
+ objectIDs: [ $element.data('objectID') ]
+ },
+ success: $.proxy(function(data, textStatus, jqXHR) {
+ // remove isRequired flag to prevent loading the same content again
+ $element.data('isRequired', false);
+
+ // update confirmation message
+ $element.data('confirmMessage', data.returnValues.confirmMessage);
+
+ // display confirmation dialog
+ this._showConfirmationDialog($element);
+ }, this)
+ });
+ }
+ else {
+ this._showConfirmationDialog($element);
+ }
+ },
+
+ /**
+ * Displays a confirmation dialog prior to package uninstallation.
+ *
+ * @param jQuery element
+ */
+ _showConfirmationDialog: function(element) {
var self = this;
- WCF.System.Confirmation.show($element.data('confirmMessage'), function(action) {
+ WCF.System.Confirmation.show(element.data('confirmMessage'), function(action) {
if (action === 'confirm') {
- self._packageID = $element.data('objectID');
+ self._packageID = element.data('objectID');
self.prepareInstallation();
}
});
<img src="{@$__wcf->getPath()}icon/update.svg" alt="" title="{lang}wcf.acp.package.button.update{/lang}" class="icon16 disabled" />
{/if}
{if $requiredPackage->canUninstall()}
- <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 jsTooltip jsUninstallButton" data-objectID="{@$requiredPackage->packageID}" data-confirm-message="{lang package=$requiredPackage}wcf.acp.package.uninstallation.confirm{/lang}" />
+ <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 jsTooltip jsUninstallButton" data-objectID="{@$requiredPackage->packageID}" data-confirm-message="{lang package=$requiredPackage}wcf.acp.package.uninstallation.confirm{/lang}" data-is-required="{$package->isRequired()}true{else}false{/if}" />
{else}
<img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 disabled" />
{/if}
<img src="{@$__wcf->getPath()}icon/update.svg" alt="" title="{lang}wcf.acp.package.button.update{/lang}" class="icon16 disabled" />
{/if}
{if $dependentPackage->canUninstall()}
- <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 jsTooltip jsUninstallButton" data-objectID="{@$dependentPackage->packageID}" data-confirm-message="{lang package=$dependentPackage}wcf.acp.package.uninstallation.confirm{/lang}" />
+ <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 jsTooltip jsUninstallButton" data-objectID="{@$dependentPackage->packageID}" data-confirm-message="{lang package=$dependentPackage}wcf.acp.package.uninstallation.confirm{/lang}" data-is-required="{$package->isRequired()}true{else}false{/if}" />
{else}
<img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 disabled" />
{/if}
<img src="{@$__wcf->getPath()}icon/update.svg" alt="" title="{lang}wcf.acp.package.button.update{/lang}" class="icon16 disabled" />
{/if}
{if $package->canUninstall()}
- <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 jsUninstallButton jsTooltip" data-object-id="{@$package->packageID}" data-confirm-message="{lang}wcf.acp.package.uninstallation.confirm{/lang}" />
+ <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 jsUninstallButton jsTooltip" data-object-id="{@$package->packageID}" data-confirm-message="{lang}wcf.acp.package.uninstallation.confirm{/lang}" data-is-required="{$package->isRequired()}true{else}false{/if}" />
{else}
<img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.acp.package.button.uninstall{/lang}" class="icon16 disabled" />
{/if}
*/
protected $dependencies = null;
- /**
- * list of packages that require this package
- * @var array<wcf\data\package\Package>
- */
- protected $dependentPackages = null;
-
/**
* installation directory
* @var string
return $this->dependencies;
}
- /**
- * Returns a list of all packages that require this package.
- * Returns packages that require this package and packages that require these packages.
- *
- * @return array<wcf\data\package\Package>
- */
- public function getDependentPackages() {
- if ($this->dependentPackages === null) {
- $this->dependentPackages = array();
-
- $sql = "SELECT package.*, CASE WHEN instanceName <> '' THEN instanceName ELSE packageName END AS packageName
- FROM wcf".WCF_N."_package_requirement package_requirement
- LEFT JOIN wcf".WCF_N."_package package ON (package.packageID = package_requirement.packageID)
- WHERE package_requirement.requirement = ?
- ORDER BY packageName ASC";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->packageID));
- while ($package = $statement->fetchObject('wcf\data\package\Package')) {
- $this->dependentPackages[$package->packageID] = $package;
- }
- }
-
- return $this->dependentPackages;
- }
-
/**
* Returns a list of the requirements of this package.
* Contains the content of the <requiredPackages> tag in the package.xml of this package.
return true;
}
+ /**
+ * Returns a list of packages dependent from current package.
+ *
+ * @return array<wcf\data\package\Package>
+ */
+ public function getDependentPackages() {
+ self::loadRequirementMap();
+
+ $packages = array();
+ if (isset(self::$requirementMap[$this->packageID])) {
+ foreach (self::$requirementMap[$this->packageID] as $packageID) {
+ $packages[$packageID] = PackageCache::getInstance()->getPackage($packageID);
+ }
+ }
+
+ return $packages;
+ }
+
/**
* Returns true, if package $packageID is required by package $targetPackageID.
*
<?php
namespace wcf\data\package;
+use wcf\system\exception\PermissionDeniedException;
+
use wcf\data\AbstractDatabaseObjectAction;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
*/
protected $permissionsUpdate = array('admin.system.package.canUpdatePackage');
+ /**
+ * package editor object
+ * @var wcf\data\package\PackageEditor
+ */
+ public $packageEditor = null;
+
/**
* Validates the 'getPluginList' action.
*/
'template' => WCF::getTPL()->fetch('packageListPlugins')
);
}
+
+ /**
+ * Validates parameters to return the confirm message for package uninstallation.
+ */
+ public function validateGetConfirmMessage() {
+ WCF::getSession()->checkPermissions($this->permissionsUpdate);
+
+ $this->packageEditor = $this->getSingleObject();
+ if (!$this->packageEditor->canUninstall()) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * Returns the confirm message for package uninstallation.
+ *
+ * @return array<string>
+ */
+ public function getConfirmMessage() {
+ return array(
+ 'confirmMessage' => WCF::getLanguage()->getDynamicVariable('wcf.acp.package.uninstallation.confirmDependentPackages', array(
+ 'package' => $this->packageEditor->getDecoratedObject(),
+ 'showDependentPackages' => true
+ ))
+ );
+ }
}
<item name="wcf.acp.package.type.other"><![CDATA[Basispaket]]></item>
<item name="wcf.acp.package.type.plugin"><![CDATA[Erweiterung]]></item>
<item name="wcf.acp.package.uninstallation.confirm"><![CDATA[Wollen Sie das Paket „{@$package->getName()}“ wirklich deinstallieren?]]></item>
+ <item name="wcf.acp.package.uninstallation.confirmDependentPackages"><![CDATA[Wollen Sie das Paket „{@$package->getName()}“ wirklich deinstallieren? Beachten Sie bitte, dass die folgenden Pakete ebenfalls deinstalliert werden:
+<ul>
+ {foreach from=$package->getDependentPackages() as $dependentPackage}
+ <li><a href="{link controller='Package' object=$dependentPackage}{/link}">{$dependentPackage}</a></li>
+ {/foreach}
+</ul>]]></item>
<item name="wcf.acp.package.updateDate"><![CDATA[Aktualisierungsdatum]]></item>
<item name="wcf.acp.package.version"><![CDATA[Version]]></item>
</category>