File size: 3,915 Bytes
e4f4821 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | <?php
namespace Kanboard\Controller;
use Kanboard\Core\Plugin\Directory;
use Kanboard\Core\Plugin\Installer;
use Kanboard\Core\Plugin\PluginInstallerException;
/**
* Class PluginController
*
* @package Kanboard\Controller
* @author Frederic Guillot
*/
class PluginController extends BaseController
{
/**
* Display the plugin page
*
* @access public
*/
public function show()
{
$this->response->html($this->helper->layout->plugin('plugin/show', array(
'plugins' => $this->pluginLoader->getPlugins(),
'incompatible_plugins' => $this->pluginLoader->getIncompatiblePlugins(),
'title' => t('Installed Plugins'),
'is_configured' => Installer::isConfigured(),
)));
}
/**
* Display list of available plugins
*/
public function directory()
{
$installedPlugins = array();
foreach ($this->pluginLoader->getPlugins() as $plugin) {
$installedPlugins[$plugin->getPluginName()] = $plugin->getPluginVersion();
}
$this->response->html($this->helper->layout->plugin('plugin/directory', array(
'installed_plugins' => $installedPlugins,
'available_plugins' => Directory::getInstance($this->container)->getAvailablePlugins(),
'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 = array_merge(
$this->pluginLoader->getPlugins(),
$this->pluginLoader->getIncompatiblePlugins()
);
$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'));
}
}
|