optional server role compatibility checks for plugins

This commit is contained in:
redmatrix 2016-08-22 17:41:41 -07:00
parent e967bc9c45
commit 38ca3bac40
4 changed files with 18 additions and 2 deletions

View file

@ -1341,6 +1341,7 @@ class Admin extends \Zotlabs\Web\Controller {
'$str_minversion' => t('Minimum project version: '),
'$str_maxversion' => t('Maximum project version: '),
'$str_minphpversion' => t('Minimum PHP version: '),
'$str_serverroles' => t('Compatible Server Roles: '),
'$str_requires' => t('Requires: '),
'$disabled' => t('Disabled - version incompatibility'),

View file

@ -612,11 +612,11 @@ function sys_boot() {
if(UNO)
App::$config['system']['server_role'] = 'basic';
else
App::$config['system']['server_role'] = 'pro';
App::$config['system']['server_role'] = 'standard';
}
if(! (array_key_exists('server_role',App::$config['system']) && App::$config['system']['server_role']))
App::$config['system']['server_role'] = 'pro';
App::$config['system']['server_role'] = 'standard';
App::$timezone = ((App::$config['system']['timezone']) ? App::$config['system']['timezone'] : 'UTC');
date_default_timezone_set(App::$timezone);

View file

@ -404,6 +404,18 @@ function check_plugin_versions($info) {
return false;
}
}
if(array_key_exists('serverroles',$info)) {
$role = \Zotlabs\Lib\System::get_server_role();
if(! (
stristr($info['serverroles'],'*')
|| stristr($info['serverroles'],'any')
|| stristr($info['serverroles'],$role))) {
logger('serverrole limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
return false;
}
}
if(array_key_exists('requires',$info)) {
$arr = explode(',',$info['requires']);

View file

@ -24,6 +24,9 @@
{{if $info.minphpversion}}
<p class="versionlimit">{{$str_minphpversion}}{{$info.minphpversion}}</p>
{{/if}}
{{if $info.serverroles}}
<p class="versionlimit">{{$str_serverroles}}{{$info.serverroles}}</p>
{{/if}}
{{if $info.requires}}
<p class="versionlimit">{{$str_requires}}{{$info.requires}}</p>
{{/if}}