From 4087dcf34bc701d137c3c57d507f101bd529004d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 6 May 2014 21:39:57 +0200 Subject: [PATCH] Some minor improvements towards Plugin-Store integration --- wcfsetup/install/files/acp/js/WCF.ACP.js | 28 +++++++++++++++++++ .../files/acp/templates/packageList.tpl | 4 ++- .../PluginStorePurchasedItemsPage.class.php | 14 +++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index edb8cbcae9..2f73a8847c 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -1592,9 +1592,21 @@ WCF.ACP.PluginStore.PurchasedItems = { }; * Searches for purchased items available for install but not yet installed. */ WCF.ACP.PluginStore.PurchasedItems.Search = Class.extend({ + /** + * dialog overlay + * @var jQuery + */ _dialog: null, + + /** + * action proxy + * @var WCF.Action.Proxy + */ _proxy: null, + /** + * Initializes the WCF.ACP.PluginStore.PurchasedItems.Search class. + */ init: function() { this._dialog = null; this._proxy = new WCF.Action.Proxy({ @@ -1605,6 +1617,9 @@ WCF.ACP.PluginStore.PurchasedItems.Search = Class.extend({ $button.prependTo($('.contentNavigation:eq(0) > nav > ul')).click($.proxy(this._click, this)); }, + /** + * Handles clicks on the search button. + */ _click: function() { this._proxy.setOption('data', { actionName: 'searchForPurchasedItems', @@ -1613,7 +1628,15 @@ WCF.ACP.PluginStore.PurchasedItems.Search = Class.extend({ this._proxy.sendRequest(); }, + /** + * Handles successful AJAX requests. + * + * @param object data + * @param string textStatus + * @param jQuery jqXHR + */ _success: function(data, textStatus, jqXHR) { + // prompt for credentials if (data.returnValues.template) { if (this._dialog === null) { this._dialog = $('
').hide().appendTo(document.body); @@ -1635,15 +1658,20 @@ WCF.ACP.PluginStore.PurchasedItems.Search = Class.extend({ }); } else if (data.returnValues.noResults) { + // there are no purchased products yet this._dialog.wcfDialog('option', 'title', WCF.Language.get('wcf.acp.pluginStore.purchasedItems')); this._dialog.html(data.returnValues.noResults); this._dialog.wcfDialog('open'); } else if (data.returnValues.redirectURL) { + // redirect to list of purchased products window.location = data.returnValues.redirectURL; } }, + /** + * Submits the user credentials. + */ _submit: function() { this._dialog.wcfDialog('close'); diff --git a/wcfsetup/install/files/acp/templates/packageList.tpl b/wcfsetup/install/files/acp/templates/packageList.tpl index a9ea2c0b2b..ccd9a002eb 100644 --- a/wcfsetup/install/files/acp/templates/packageList.tpl +++ b/wcfsetup/install/files/acp/templates/packageList.tpl @@ -27,7 +27,9 @@ new WCF.ACP.Package.Update.Search(); {/if} - new WCF.ACP.PluginStore.PurchasedItems.Search(); + {if $__wcf->session->getPermission('admin.system.package.canUpdatePackage') && $__wcf->session->getPermission('admin.system.package.canUninstallPackage')} + new WCF.ACP.PluginStore.PurchasedItems.Search(); + {/if} }); //]]> diff --git a/wcfsetup/install/files/lib/acp/page/PluginStorePurchasedItemsPage.class.php b/wcfsetup/install/files/lib/acp/page/PluginStorePurchasedItemsPage.class.php index 0a7870ccce..85ca5d3ba3 100644 --- a/wcfsetup/install/files/lib/acp/page/PluginStorePurchasedItemsPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PluginStorePurchasedItemsPage.class.php @@ -29,15 +29,27 @@ class PluginStorePurchasedItemsPage extends AbstractPage { public $neededPermissions = array('admin.system.package.canUpdatePackage', 'admin.system.package.canUninstallPackage'); /** - * list of purchased products grouped by WCF major release. + * list of purchased products grouped by WCF major release * @var array */ public $products = array(); + /** + * list of product data grouped by WCF major release + * @var array + */ public $productData = array(); + /** + * list of installed update servers (Plugin-Store only) + * @var array<\wcf\data\package\update\server\PackageUpdateServer> + */ public $updateServers = array(); + /** + * list of supported WCF major releases (Plugin-Store) + * @var array + */ public $wcfMajorReleases = array(); /** -- 2.20.1