diff options
Diffstat (limited to 'include/plugin.php')
-rwxr-xr-x | include/plugin.php | 75 |
1 files changed, 54 insertions, 21 deletions
diff --git a/include/plugin.php b/include/plugin.php index 4a35a0170..bd844442f 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -291,7 +291,7 @@ function call_hooks($name, &$data = null) { $func = $hook[1]; $func($a, $data); } else { - // remove orphan hooks + q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND function = '%s'", dbesc($name), dbesc($hook[0]), @@ -313,7 +313,6 @@ function call_hooks($name, &$data = null) { * * Version: 1.2.3 * * Author: John <profile url> * * Author: Jane <email> - * * Compat: Red [(version)], Friendica [(version)] * * *\endcode * @param string $plugin the name of the plugin @@ -325,8 +324,9 @@ function get_plugin_info($plugin){ 'name' => $plugin, 'description' => '', 'author' => array(), + 'maintainer' => array(), 'version' => '', - 'compat' => '' + 'requires' => '' ); if (!is_file("addon/$plugin/$plugin.php")) @@ -342,17 +342,16 @@ function get_plugin_info($plugin){ if ($l != ""){ list($k, $v) = array_map("trim", explode(":", $l, 2)); $k = strtolower($k); - if ($k == 'author'){ + if ($k == 'author' || $k == 'maintainer'){ $r = preg_match("|([^<]+)<([^>]+)>|", $v, $m); if ($r) { - $info['author'][] = array('name' => $m[1], 'link' => $m[2]); + $info[$k][] = array('name' => $m[1], 'link' => $m[2]); } else { - $info['author'][] = array('name' => $v); - } - } else { - if (array_key_exists($k, $info)){ - $info[$k] = $v; + $info[$k][] = array('name' => $v); } + } + else { + $info[$k] = $v; } } } @@ -361,6 +360,51 @@ function get_plugin_info($plugin){ return $info; } +function check_plugin_versions($info) { + + if(! is_array($info)) + return true; + + if(array_key_exists('minversion',$info)) { + if(! version_compare(STD_VERSION,trim($info['minversion']), '>=')) { + logger('minversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); + return false; + } + } + if(array_key_exists('maxversion',$info)) { + if(version_compare(STD_VERSION,trim($info['maxversion']), '>')) { + logger('maxversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); + return false; + } + } + if(array_key_exists('minphpversion',$info)) { + if(! version_compare(PHP_VERSION,trim($info['minphpversion']), '>=')) { + logger('minphpversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); + return false; + } + } + + if(array_key_exists('requires',$info)) { + $arr = explode(',',$info['requires']); + $found = true; + if($arr) { + foreach($arr as $test) { + $test = trim($test); + if(! $test) + continue; + if(! in_array($test,get_app()->plugins)) + $found = false; + } + } + if(! $found) + return false; + } + + return true; +} + + + /** * @brief Parse theme comment in search of theme infos. @@ -626,17 +670,6 @@ function get_markup_template($s, $root = '') { return $template; } -// return the standardised version. Since we can't easily compare -// before the STD_VERSION definition was applied, we have to treat -// all prior release versions the same. You can dig through them -// with other means (such as RED_VERSION) if necessary. - -function get_std_version() { - if(defined('STD_VERSION')) - return STD_VERSION; - return '0.0.0'; -} - function folder_exists($folder) { |