blob: 21f11ca9251a3e3571185cc4e58a3fca263487a4 (
plain)
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
|
<?php
namespace Kanboard\Core\Plugin;
use Kanboard\Core\Base as BaseCore;
/**
* Class Directory
*
* @package Kanboard\Core\Plugin
* @author Frederic Guillot
*/
class Directory extends BaseCore
{
/**
* Get all plugins available
*
* @access public
* @param string $url
* @return array
*/
public function getAvailablePlugins($url = PLUGIN_API_URL)
{
$plugins = $this->httpClient->getJson($url);
$plugins = array_filter($plugins, array($this, 'isCompatible'));
$plugins = array_filter($plugins, array($this, 'isInstallable'));
return $plugins;
}
/**
* Filter plugins
*
* @param array $plugin
* @param string $appVersion
* @return bool
*/
public function isCompatible(array $plugin, $appVersion = APP_VERSION)
{
if (strpos($appVersion, 'master') !== false) {
return true;
}
return $plugin['compatible_version'] === $appVersion;
}
/**
* Filter plugins
*
* @param array $plugin
* @return bool
*/
public function isInstallable(array $plugin)
{
return $plugin['remote_install'];
}
}
|