diff options
author | redmatrix <git@macgirvin.com> | 2016-01-11 16:34:12 -0800 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-01-11 16:34:12 -0800 |
commit | 66c8658898b16f6a6468bddbbc6f882b3eaf3a7d (patch) | |
tree | ab823b8a9c4be9f4cf218ac08f7e2a52267b4f4c /mod/admin.php | |
parent | f4d47f825df40095f5b66b039dc6ca2d689e6b16 (diff) | |
download | volse-hubzilla-66c8658898b16f6a6468bddbbc6f882b3eaf3a7d.tar.gz volse-hubzilla-66c8658898b16f6a6468bddbbc6f882b3eaf3a7d.tar.bz2 volse-hubzilla-66c8658898b16f6a6468bddbbc6f882b3eaf3a7d.zip |
plugin version compatibility checking. To use, set MinVersion, MaxVersion or MinPHPversion in the plugin header block. Case is not important. We check the project versions against STD_VERSION, which should be rolled to a new y of x.x.y if the plugin interface or project code changes in an incompatible way.
Diffstat (limited to 'mod/admin.php')
-rw-r--r-- | mod/admin.php | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/mod/admin.php b/mod/admin.php index c175a4a61..2d859399b 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1092,6 +1092,23 @@ function admin_page_plugins(&$a){ return ''; } + $enabled = in_array($plugin,$a->plugins); + $info = get_plugin_info($plugin); + $x = check_plugin_versions($info); + + // disable plugins which are installed but incompatible versions + + if($enabled && ! $x) { + $enabled = false; + $idz = array_search($plugin, $a->plugins); + if ($idz !== false) { + unset($a->plugins[$idz]); + uninstall_plugin($plugin); + set_config("system","addon", implode(", ",$a->plugins)); + } + } + $info['disabled'] = 1-intval($x); + if (x($_GET,"a") && $_GET['a']=="t"){ check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't'); @@ -1142,6 +1159,7 @@ function admin_page_plugins(&$a){ } } + $t = get_markup_template('admin_plugins_details.tpl'); return replace_macros($t, array( '$title' => t('Administration'), @@ -1153,9 +1171,14 @@ function admin_page_plugins(&$a){ '$plugin' => $plugin, '$status' => $status, '$action' => $action, - '$info' => get_plugin_info($plugin), + '$info' => $info, '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), + '$str_minversion' => t('Minimum project version: '), + '$str_maxversion' => t('Maximum project version: '), + '$str_minphpversion' => t('Minimum PHP version: '), + + '$disabled' => t('Disabled - version incompatibility'), '$admin_form' => $admin_form, '$function' => 'plugins', @@ -1177,7 +1200,23 @@ function admin_page_plugins(&$a){ if (is_dir($file)){ list($tmp, $id) = array_map('trim', explode('/', $file)); $info = get_plugin_info($id); - $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info); + $enabled = in_array($id,$a->plugins); + $x = check_plugin_versions($info); + + // disable plugins which are installed but incompatible versions + + if($enabled && ! $x) { + $enabled = false; + $idz = array_search($id, $a->plugins); + if ($idz !== false) { + unset($a->plugins[$idz]); + uninstall_plugin($id); + set_config("system","addon", implode(", ",$a->plugins)); + } + } + $info['disabled'] = 1-intval($x); + + $plugins[] = array( $id, (($enabled)?"on":"off") , $info); } } } @@ -1190,6 +1229,7 @@ function admin_page_plugins(&$a){ '$baseurl' => $a->get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, + '$disabled' => t('Disabled - version incompatibility'), '$form_security_token' => get_form_security_token('admin_plugins'), )); } |