summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-20 12:51:05 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-20 12:51:05 -0400
commit8d69c49da595c60dae51c77d48f397ab97fdf318 (patch)
tree7fba4edb18c5c4c161e76828d5847733aca8d27b /app/Controller
parentcbf896e74e666f102f475787202d3402f229a919 (diff)
Manage plugins from the user interface and from the command line
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/PluginController.php93
1 files changed, 90 insertions, 3 deletions
diff --git a/app/Controller/PluginController.php b/app/Controller/PluginController.php
index 8d5628f1..b6f9a33b 100644
--- a/app/Controller/PluginController.php
+++ b/app/Controller/PluginController.php
@@ -2,6 +2,9 @@
namespace Kanboard\Controller;
+use Kanboard\Core\Plugin\Installer;
+use Kanboard\Core\Plugin\PluginInstallerException;
+
/**
* Class PluginController
*
@@ -18,8 +21,9 @@ class PluginController extends BaseController
public function show()
{
$this->response->html($this->helper->layout->plugin('plugin/show', array(
- 'plugins' => $this->pluginLoader->plugins,
+ 'plugins' => $this->pluginLoader->getPlugins(),
'title' => t('Installed Plugins'),
+ 'is_configured' => Installer::isConfigured(),
)));
}
@@ -28,11 +32,94 @@ class PluginController extends BaseController
*/
public function directory()
{
- $plugins = $this->httpClient->getJson(PLUGIN_API_URL);
+ $installedPlugins = array();
+
+ foreach ($this->pluginLoader->getPlugins() as $plugin) {
+ $installedPlugins[$plugin->getPluginName()] = $plugin->getPluginVersion();
+ }
$this->response->html($this->helper->layout->plugin('plugin/directory', array(
- 'plugins' => $plugins,
+ 'installed_plugins' => $installedPlugins,
+ 'available_plugins' => $this->httpClient->getJson(PLUGIN_API_URL),
'title' => t('Plugin Directory'),
+ 'is_configured' => Installer::isConfigured(),
)));
}
+
+ /**
+ * Install plugin from URL
+ *
+ * @throws \Kanboard\Core\Controller\AccessForbiddenException
+ */
+ public function install()
+ {
+ $this->checkCSRFParam();
+ $pluginArchiveUrl = urldecode($this->request->getStringParam('archive_url'));
+
+ try {
+ $installer = new Installer($this->container);
+ $installer->install($pluginArchiveUrl);
+ $this->flash->success(t('Plugin installed successfully.'));
+ } catch (PluginInstallerException $e) {
+ $this->flash->failure($e->getMessage());
+ }
+
+ $this->response->redirect($this->helper->url->to('PluginController', 'show'));
+ }
+
+ /**
+ * Update plugin from URL
+ *
+ * @throws \Kanboard\Core\Controller\AccessForbiddenException
+ */
+ public function update()
+ {
+ $this->checkCSRFParam();
+ $pluginArchiveUrl = urldecode($this->request->getStringParam('archive_url'));
+
+ try {
+ $installer = new Installer($this->container);
+ $installer->update($pluginArchiveUrl);
+ $this->flash->success(t('Plugin updated successfully.'));
+ } catch (PluginInstallerException $e) {
+ $this->flash->failure($e->getMessage());
+ }
+
+ $this->response->redirect($this->helper->url->to('PluginController', 'show'));
+ }
+
+ /**
+ * Confirmation before to remove the plugin
+ */
+ public function confirm()
+ {
+ $pluginId = $this->request->getStringParam('pluginId');
+ $plugins = $this->pluginLoader->getPlugins();
+
+ $this->response->html($this->template->render('plugin/remove', array(
+ 'plugin_id' => $pluginId,
+ 'plugin' => $plugins[$pluginId],
+ )));
+ }
+
+ /**
+ * Remove a plugin
+ *
+ * @throws \Kanboard\Core\Controller\AccessForbiddenException
+ */
+ public function uninstall()
+ {
+ $this->checkCSRFParam();
+ $pluginId = $this->request->getStringParam('pluginId');
+
+ try {
+ $installer = new Installer($this->container);
+ $installer->uninstall($pluginId);
+ $this->flash->success(t('Plugin removed successfully.'));
+ } catch (PluginInstallerException $e) {
+ $this->flash->failure($e->getMessage());
+ }
+
+ $this->response->redirect($this->helper->url->to('PluginController', 'show'));
+ }
}