|
|
<?php |
|
|
|
|
|
namespace Kanboard\Controller; |
|
|
|
|
|
use Kanboard\Core\Plugin\Directory; |
|
|
use Kanboard\Core\Plugin\Installer; |
|
|
use Kanboard\Core\Plugin\PluginInstallerException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PluginController extends BaseController |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(), |
|
|
))); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(), |
|
|
))); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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], |
|
|
))); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')); |
|
|
} |
|
|
} |
|
|
|