aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinclude/plugin.php37
-rw-r--r--mod/admin.php44
-rw-r--r--version.inc2
-rwxr-xr-xview/tpl/admin_plugins.tpl6
-rwxr-xr-xview/tpl/admin_plugins_details.tpl19
5 files changed, 97 insertions, 11 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 4da73dfd8..ccd88d963 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -348,19 +348,46 @@ function get_plugin_info($plugin){
} else {
$info[$k][] = array('name' => $v);
}
- } else {
-// if (array_key_exists($k, $info)){
- $info[$k] = $v;
-// }
+ }
+ else {
+ $info[$k] = $v;
}
}
}
}
-
return $info;
}
+function check_plugin_versions($info) {
+
+ if(! is_array($info))
+ return true;
+
+ if(array_key_exists('minversion',$info)) {
+ if(version_compare(trim($info['minversion']),STD_VERSION, '<')) {
+ logger('minversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+ if(array_key_exists('maxversion',$info)) {
+ if(version_compare(trim($info['maxversion']),STD_VERSION, '>')) {
+ logger('maxversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+ if(array_key_exists('minphpversion',$info)) {
+ if(version_compare(trim($info['minphpversion']),PHP_VERSION, '<')) {
+ logger('minphpversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+
/**
* @brief Parse theme comment in search of theme infos.
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'),
));
}
diff --git a/version.inc b/version.inc
index 3641bf5e9..c17fa0d99 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2016-01-10.1274H
+2016-01-11.1275H
diff --git a/view/tpl/admin_plugins.tpl b/view/tpl/admin_plugins.tpl
index 0f76cc4fe..0da214c17 100755
--- a/view/tpl/admin_plugins.tpl
+++ b/view/tpl/admin_plugins.tpl
@@ -4,8 +4,12 @@
<ul id='pluginslist'>
{{foreach $plugins as $p}}
<li class='plugin {{$p.1}}'>
+ {{if ! $p.2.disabled}}
<a class='toggleplugin' href='{{$baseurl}}/admin/{{$function}}/{{$p.0}}?a=t&amp;t={{$form_security_token}}' title="{{if $p.1==on}}Disable{{else}}Enable{{/if}}" ><i class='{{if $p.1==on}}icon-check{{else}}icon-check-empty{{/if}} admin-icons'></i></a>
- <a href='{{$baseurl}}/admin/{{$function}}/{{$p.0}}'><span class='name'>{{$p.2.name}}</span></a> - <span class="version">{{$p.2.version}}</span>
+ {{else}}
+ <i class='icon-stop admin-icons'></i>
+ {{/if}}
+ <a href='{{$baseurl}}/admin/{{$function}}/{{$p.0}}'><span class='name'>{{$p.2.name}}</span></a> - <span class="version">{{$p.2.version}}</span>{{if $p.2.disabled}} {{$disabled}}{{/if}}
{{if $p.2.experimental}} {{$experimental}} {{/if}}{{if $p.2.unsupported}} {{$unsupported}} {{/if}}
<div class='desc'>{{$p.2.description}}</div>
diff --git a/view/tpl/admin_plugins_details.tpl b/view/tpl/admin_plugins_details.tpl
index 6225ae7bf..721bd3573 100755
--- a/view/tpl/admin_plugins_details.tpl
+++ b/view/tpl/admin_plugins_details.tpl
@@ -1,7 +1,12 @@
<div class = "generic-content-wrapper-styled" id='adminpage'>
<h1>{{$title}} - {{$page}}</h1>
-
- <p><i class='toggleplugin {{if $status==on}}icon-check{{else}}icon-check-empty{{/if}} admin-icons'></i> {{$info.name}} - {{$info.version}} : <a href="{{$baseurl}}/admin/{{$function}}/{{$plugin}}/?a=t&amp;t={{$form_security_token}}">{{$action}}</a></p>
+
+ <p>{{if ! $info.disabled}}<i class='toggleplugin {{if $status==on}}icon-check{{else}}icon-check-empty{{/if}} admin-icons'></i>{{else}}<i class='icon-stop admin-icons'></i>{{/if}} {{$info.name}} - {{$info.version}}{{if ! $info.disabled}} : <a href="{{$baseurl}}/admin/{{$function}}/{{$plugin}}/?a=t&amp;t={{$form_security_token}}">{{$action}}</a>{{/if}}</p>
+
+ {{if $info.disabled}}
+ <p>{{$disabled}}</p>
+ {{/if}}
+
<p>{{$info.description}}</p>
{{foreach $info.author as $a}}
@@ -10,6 +15,16 @@
</p>
{{/foreach}}
+ {{if $info.minversion}}
+ <p class="versionlimit">{{$str_minversion}}{{$info.minversion}}</p>
+ {{/if}}
+ {{if $info.maxversion}}
+ <p class="versionlimit">{{$str_maxversion}}{{$info.maxversion}}</p>
+ {{/if}}
+ {{if $info.minphpversion}}
+ <p class="versionlimit">{{$str_minphpversion}}{{$info.minphpversion}}</p>
+ {{/if}}
+
{{foreach $info.maintainer as $a}}
<p class="maintainer">{{$str_maintainer}}