diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-03-07 05:24:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-07 05:24:03 +0300 |
commit | e2b9414bf29c12bab57dc7c9630243738e90b458 (patch) | |
tree | bca6e3df5e745cfc0107dab61f1c318cdad51d83 /plugins/Marketplace | |
parent | 0d5d0dfe40f771d437fa0bf36e8393daa3da07d3 (diff) |
Allow updating multiple plugins at once. (#14052)
* Allow updating multiple plugins at once.
* Disable checkbox if plugin is not downloadable.
* Fix translation typo.
* really fix typo
Diffstat (limited to 'plugins/Marketplace')
-rw-r--r-- | plugins/Marketplace/Controller.php | 47 | ||||
-rw-r--r-- | plugins/Marketplace/templates/installPlugin.twig | 2 | ||||
-rw-r--r-- | plugins/Marketplace/templates/updatePlugin.twig | 5 |
3 files changed, 33 insertions, 21 deletions
diff --git a/plugins/Marketplace/Controller.php b/plugins/Marketplace/Controller.php index 407eb86aa8..ca39fc1958 100644 --- a/plugins/Marketplace/Controller.php +++ b/plugins/Marketplace/Controller.php @@ -393,32 +393,36 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->dieIfPluginsAdminIsDisabled(); $this->displayWarningIfConfigFileNotWritable(); - $pluginName = $this->getPluginNameIfNonceValid($nonceName); + $plugins = $this->getPluginNameIfNonceValid($nonceName); $view = new View('@Marketplace/' . $template); $this->setBasicVariablesView($view); $view->errorMessage = ''; - $view->plugin = array('name' => $pluginName); - try { - $this->pluginInstaller->installOrUpdatePluginFromMarketplace($pluginName); + $pluginInfos = []; + foreach ($plugins as $pluginName) { + $pluginInfos[] = $this->plugins->getPluginInfo($pluginName); - } catch (\Exception $e) { + try { + $this->pluginInstaller->installOrUpdatePluginFromMarketplace($pluginName); - $notification = new Notification($e->getMessage()); - $notification->context = Notification::CONTEXT_ERROR; - $notification->type = Notification::TYPE_PERSISTENT; - $notification->flags = Notification::FLAG_CLEAR; - if (method_exists($e, 'isHtmlMessage') && $e->isHtmlMessage()) { - $notification->raw = true; - } - Notification\Manager::notify('CorePluginsAdmin_InstallPlugin', $notification); + } catch (\Exception $e) { - Url::redirectToReferrer(); - return; + $notification = new Notification($e->getMessage()); + $notification->context = Notification::CONTEXT_ERROR; + $notification->type = Notification::TYPE_PERSISTENT; + $notification->flags = Notification::FLAG_CLEAR; + if (method_exists($e, 'isHtmlMessage') && $e->isHtmlMessage()) { + $notification->raw = true; + } + Notification\Manager::notify('CorePluginsAdmin_InstallPlugin', $notification); + + Url::redirectToReferrer(); + return; + } } - $view->plugin = $this->plugins->getPluginInfo($pluginName); + $view->plugins = $pluginInfos; return $view; } @@ -435,11 +439,14 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $pluginName = Common::getRequestVar('pluginName', null, 'string'); - if (!$this->pluginManager->isValidPluginName($pluginName)) { - throw new Exception('Invalid plugin name'); + $plugins = explode(',', $pluginName); + $plugins = array_map('trim', $plugins); + foreach ($plugins as $name) { + if (!$this->pluginManager->isValidPluginName($name)) { + throw new Exception('Invalid plugin name: ' . $name); + } } - - return $pluginName; + return $plugins; } private function dieIfPluginsAdminIsDisabled() diff --git a/plugins/Marketplace/templates/installPlugin.twig b/plugins/Marketplace/templates/installPlugin.twig index 7182ed9d16..4c1d3864b8 100644 --- a/plugins/Marketplace/templates/installPlugin.twig +++ b/plugins/Marketplace/templates/installPlugin.twig @@ -4,6 +4,7 @@ <div style="max-width:980px;"> + {% for plugin in plugins %} <h2>{{ 'Marketplace_InstallingPlugin'|translate(plugin.name) }}</h2> <div> @@ -36,6 +37,7 @@ {% endif %} </div> + {% endfor %} </div> {% endblock %} diff --git a/plugins/Marketplace/templates/updatePlugin.twig b/plugins/Marketplace/templates/updatePlugin.twig index ec920cda92..f9fe08bde8 100644 --- a/plugins/Marketplace/templates/updatePlugin.twig +++ b/plugins/Marketplace/templates/updatePlugin.twig @@ -4,6 +4,7 @@ <div style="max-width:980px;"> + {% for plugin in plugins %} <h2>{{ 'Marketplace_UpdatingPlugin'|translate(plugin.name) }}</h2> <div> @@ -29,7 +30,9 @@ <p>{{ 'Marketplace_StepPluginSuccessfullyUpdated'|translate(plugin.name, plugin.latestVersion) }}</p> {% endif %} - + </div> + {% endfor %} + <div> <p><a href="{{ linkTo({'module': 'CorePluginsAdmin', 'action': 'plugins'}) }}">{{ 'General_Plugins'|translate }}</a> | <a href="{{ linkTo({'module': 'CorePluginsAdmin', 'action': 'themes'}) }}">{{ 'CorePluginsAdmin_Themes'|translate }}</a> |